using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using GThinking.N_MISPRO; using GThinking.N_MISPRO.Data; using GThinking.N_MODEL.Page; using GThinking.N_MISPRO.Utility; using GThinking.N_PUBLIC; using GThinking.N_MODEL.Dialog; namespace GThinking.N_XLXSBJ { public partial class BJYFJJQJInfo : SingleCardBase { BJYFJJQJ entity = new BJYFJJQJ(); protected void Page_Load(object sender, EventArgs e) { this.UMID = 100860071; this.UMName = "线缆销售报价单运费"; this.CurMaster = Master; this.CurEntity = entity; this.PageHeight = 400; this.PageWidth = 500; base.InitPage(); if (!IsPostBack) { initControl(); } } #region 模板事件继承 protected override void SetControlState() { base.SetControlState(); txtYFJSGS.Enabled = false; txtWHR.Enabled = false; datWHSJ.Enabled = false; } protected override void LoadRecord() { if (!IsPostBack) { entity.Param.Add("OLD_XLXSBJYFJJQJ_YFJJQH", PageParam.GetRTrimString("XLXSBJYFJJQJ_YFJJQH")); } else { entity.Param.Add("OLD_XLXSBJYFJJQJ_YFJJQH", txtOLD_YFJJQH.Value); } base.LoadRecord(); txtOLD_YFJJQH.Value = txtYFJJQH.Text.Trim(); } protected override void OnNewRecorder() { base.OnNewRecorder(); txtYFJSGS.Text = "运率*运件"; txtWHR.Text = tSession.UserName; txtWHRID.Value = tSession.UserId; datWHSJ.Text = CMISproConvert.ConvertTime(DateTime.Now); } protected override void OnCopyRecorder() { base.OnCopyRecorder(); txtWHR.Text = tSession.UserName; txtWHRID.Value = tSession.UserId; datWHSJ.Text = CMISproConvert.ConvertTime(DateTime.Now); } protected override bool DataLogicValid() { if (!base.DataLogicValid()) return false; if (txtPJWJXX.Value < 0) { ShowMessage("计件区间下限--不允许为负数!"); return false; } if (txtPJWJSX.Value < 0) { ShowMessage("计件区间上限--不允许为负数!"); return false; } if (txtPJWJSX.Value != 0) { if (txtPJWJXX.Value >= txtPJWJSX.Value) { ShowMessage("计件区间下限必须小于计件区间上限!"); return false; } } TDatabase dberp = TContextDatabases.GetDatabase("DBERP"); TSQL sql = new TSQL(dberp); if (ControlState == TControlState.ctsInsert || ControlState == TControlState.ctsCopy) { sql.Clear(); sql.Add("select XLXSBJYFJJQJ_PJWJXX,XLXSBJYFJJQJ_PJWJSX from XLXSBJYFJJQJ where 1=1 "); sql.Add(" and XLXSBJYFJJQJ_PJCZ = :PJCZ"); sql.ParamByName("PJCZ").Value = cbxPJCZ.SelectedValue.Trim(); sql.Add(" and ((XLXSBJYFJJQJ_PJWJXX>=:pPJWJXX "); if (txtPJWJSX.Value != 0) { sql.Add(" and XLXSBJYFJJQJ_PJWJXX<:pPJWJSX "); } sql.Add(" ) "); sql.Add(" or ("); if (txtPJWJSX.Value != 0) { sql.Add(" XLXSBJYFJJQJ_PJWJSX>0 and XLXSBJYFJJQJ_PJWJSX>:pPJWJXX and XLXSBJYFJJQJ_PJWJSX<=:pPJWJSX "); } else { sql.Add(" (XLXSBJYFJJQJ_PJWJSX>0 and XLXSBJYFJJQJ_PJWJSX>:pPJWJXX) or (XLXSBJYFJJQJ_PJWJSX=0) "); } sql.Add(" ) "); sql.Add(" or (XLXSBJYFJJQJ_PJWJXX<:pPJWJXX and (XLXSBJYFJJQJ_PJWJSX=0 or XLXSBJYFJJQJ_PJWJSX>:pPJWJSX))"); sql.Add(" ) "); sql.ParamByName("pPJWJXX").Value = txtPJWJXX.Value; if (txtPJWJSX.Value != 0) { sql.ParamByName("pPJWJSX").Value = txtPJWJSX.Value; } DataSet ds = dberp.OpenDataSet(sql); if (ds.Tables[0].Rows.Count > 0) { string sYFJZQJ = ""; if (CMISproConvert.StrToFloat(ds.Tables[0].Rows[0]["XLXSBJYFJJQJ_PJWJSX"].ToString()) != 0) sYFJZQJ = ds.Tables[0].Rows[0]["XLXSBJYFJJQJ_PJWJXX"].ToString().Trim() + "~" + ds.Tables[0].Rows[0]["XLXSBJYFJJQJ_PJWJSX"].ToString().Trim() + "mm"; else sYFJZQJ = ds.Tables[0].Rows[0]["XLXSBJYFJJQJ_PJWJXX"].ToString().Trim() + "~" + "--" + "mm"; ShowMessage(string.Format("与已有计件区间【{0}】有交集,不允许保存!", sYFJZQJ)); return false; } } else { sql.Clear(); sql.Add("select XLXSBJYFJJQJ_PJWJXX,XLXSBJYFJJQJ_PJWJSX from XLXSBJYFJJQJ where XLXSBJYFJJQJ_YFJJQH<>:OLDYFJJQH "); sql.Add(" and XLXSBJYFJJQJ_PJCZ = :PJCZ"); sql.ParamByName("PJCZ").Value = cbxPJCZ.SelectedValue.Trim(); sql.Add(" and ((XLXSBJYFJJQJ_PJWJXX>=:pPJWJXX "); if (txtPJWJSX.Value != 0) { sql.Add(" and XLXSBJYFJJQJ_PJWJXX<:pPJWJSX "); } sql.Add(" ) "); sql.Add(" or ("); if (txtPJWJSX.Value != 0) { sql.Add(" XLXSBJYFJJQJ_PJWJSX>0 and XLXSBJYFJJQJ_PJWJSX>:pPJWJXX and XLXSBJYFJJQJ_PJWJSX<=:pPJWJSX "); } else { sql.Add(" (XLXSBJYFJJQJ_PJWJSX>0 and XLXSBJYFJJQJ_PJWJSX>:pPJWJXX) or (XLXSBJYFJJQJ_PJWJSX=0) "); } sql.Add(" ) "); sql.Add(" or (XLXSBJYFJJQJ_PJWJXX<:pPJWJXX and (XLXSBJYFJJQJ_PJWJSX=0 or XLXSBJYFJJQJ_PJWJSX>:pPJWJSX))"); sql.Add(" ) "); sql.ParamByName("OLDYFJJQH").Value = txtOLD_YFJJQH.Value.Trim(); sql.ParamByName("pPJWJXX").Value = txtPJWJXX.Value; if (txtPJWJSX.Value != 0) { sql.ParamByName("pPJWJSX").Value = txtPJWJSX.Value; } DataSet ds = dberp.OpenDataSet(sql); if (ds.Tables[0].Rows.Count > 0) { string sYFJZQJ = ""; if (CMISproConvert.StrToFloat(ds.Tables[0].Rows[0]["XLXSBJYFJJQJ_PJWJSX"].ToString()) != 0) sYFJZQJ = ds.Tables[0].Rows[0]["XLXSBJYFJJQJ_PJWJXX"].ToString().Trim() + "~" + ds.Tables[0].Rows[0]["XLXSBJYFJJQJ_PJWJSX"].ToString().Trim() + "mm"; else sYFJZQJ = ds.Tables[0].Rows[0]["XLXSBJYFJJQJ_PJWJXX"].ToString().Trim() + "~" + "--" + "mm"; ShowMessage(string.Format("与已有计件区间【{0}】有交集,不允许保存!", sYFJZQJ)); return false; } } return true; } protected override bool Master_BeforeSaveAction(object sender, EventArgs e) { if (!base.Master_BeforeSaveAction(sender, e)) return false; txtWHR.Text = tSession.UserName; txtWHRID.Value = tSession.UserId; datWHSJ.Text = CMISproConvert.ConvertTime(System.DateTime.Now); return true; } protected override bool Master_AfterSaveAction(object sender, EventArgs e) { txtOLD_YFJJQH.Value = txtYFJJQH.Text.Trim(); return base.Master_AfterSaveAction(sender, e); } protected override void AfterSave(TDatabase db, ref bool ActionIsDone) { base.AfterSave(db, ref ActionIsDone); //UpdateXJXSYQY(cbxQY.SelectedValue.Trim(), txtSJXSYBH.Text.Trim()); } #endregion #region 控件事件 #endregion private void initControl() { cbxPJCZ.ClearItems(); cbxPJCZ.Items.Add(new ListItem("铁木盘", "TMP")); cbxPJCZ.Items.Add(new ListItem("全铁盘", "QTP")); cbxPJCZ.Items.Add(new ListItem("全木盘", "QMP")); cbxPJCZ.Items.Add(new ListItem("出口铁木盘", "CKTMP")); cbxPJCZ.Items.Add(new ListItem("加固铁木盘", "JGTMP")); cbxPJCZ.Items.Add(new ListItem("加固出口铁木盘", "JGCKTMP")); cbxPJCZ.ShowValue = false; } } }