/// <summary> /// 获取信息 /// </summary> /// <param name="">条件</param> /// <returns>*信息</returns> public ProduceTrack Get(ProduceTrack model) { List <ProduceTrack> list = null; string sql = null; List <DataParameter> parameters = new List <DataParameter>(); using (IDataSession session = AppDataFactory.CreateMainSession()) { sql = @"SELECT T1.*,T2.PNAME,T3.BARCODE AS CBBARCODE,T3.ENAME AS CBNAME,T4.WSCODE,T5.PNAME AS GXNAME FROM T_FP_PRODUCETRACK T1 LEFT OUTER JOIN T_FP_PRODUCTINFO T2 ON T1.PRODUCTIONID = T2.PRID LEFT OUTER JOIN T_FP_EQUIPMENT T3 ON T1.EQUID = T3.PID LEFT OUTER JOIN T_FP_WORKSTATION T4 ON T1.WSID = T4.PID LEFT OUTER JOIN T_FP_PROCESSINFO T5 ON T1.WPID = T5.PID WHERE T1.PID =@PID"; parameters.Add(new DataParameter("PID", model.PID)); list = session.GetList <ProduceTrack>(sql, parameters.ToArray()).ToList <ProduceTrack>(); } if (list.Count > 0) { return(list[0]); } else { return(null); } }
/// <summary> /// 获取列表 /// </summary> /// <param name="condition">条件</param> /// <param name="page">数据页</param> /// <returns>数据页</returns> public DataPage GetList(ProduceTrack condition, DataPage page) { string sql = null; List <DataParameter> parameters = new List <DataParameter>(); try { sql = this.GetQuerySql(condition, ref parameters); //分页关键字段及排序 page.KeyName = "t1.PID"; if (string.IsNullOrEmpty(page.SortExpression)) { page.SortExpression = "t1.UPDATETIME DESC"; } using (IDataSession session = AppDataFactory.CreateMainSession()) { page = session.GetDataPage <ProduceTrack>(sql, parameters.ToArray(), page); } return(page); } catch (Exception ex) { throw ex; } }
protected void btSave_Click(object sender, EventArgs e) { ProduceTrack info = new ProduceTrack(); ProduceTrackBLL bll = null; try { UIBindHelper.BindModelByControls(this.Page, info); bll = BLLFactory.CreateBLL <ProduceTrackBLL>(); if (this.hiID.Value == "") { info.MATID = this.hiMatID.Value; info.STATUS = "1"; info.WPID = "start"; info.MATBARCODE = this.HiMatBarCode.Value; bll.Insert(info); } ClientScript.RegisterStartupScript(this.GetType(), "myjs", "alert('原料上线完成');window.location.href='MaterialOnline.aspx';", true); } catch (Exception ex) { throw ex; } }
protected void btReset_Click(object sender, EventArgs e) { ProduceTrack info = new ProduceTrack(); ProduceTrackBLL bll = null; try { UIBindHelper.BindModelByControls(this.Page, info); bll = BLLFactory.CreateBLL <ProduceTrackBLL>(); info.PID = this.hiID.Value; info.STATUS = "0"; info.WPID = this.hiGX.Value; info.EQUID = this.hiCB.Value; info.WSID = this.hiGW.Value; info.PRODUCTIONID = this.hiPid.Value; info.WORKINGSTARTTIME = DateTime.MinValue; bll.Update(info); BindData(info.PID); } catch (Exception ex) { throw ex; } }
protected void btEnd_Click(object sender, EventArgs e) { ProduceTrack info = new ProduceTrack(); ProduceTrackBLL bll = null; try { UIBindHelper.BindModelByControls(this.Page, info); bll = BLLFactory.CreateBLL <ProduceTrackBLL>(); info.PID = this.hiID.Value; info.WORKINGENDTIME = DateTime.Now; info.STATUS = "1"; info.WPID = this.hiGX.Value; info.EQUID = this.hiCB.Value; info.WSID = this.hiGW.Value; info.PRODUCTIONID = this.hiPid.Value; info.CREATETIME = DateTime.Parse(this.HiCREATETIME.Value); info.CREATEUSER = this.HiCREATEUSER.Value; bll.Update(info); ClientScript.RegisterStartupScript(this.GetType(), "myjs", "alert('完成');window.location.href='MaterialTrace.aspx';", true); } catch (Exception ex) { throw ex; } }
/// <summary> /// 更新信息 /// </summary> /// <param name="">信息</param> /// <returns>更新行数</returns> public DataResult <int> Update(ProduceTrack model) { DataResult <int> result = new DataResult <int>(); try { //获取生产计划信息 ProducePlan plan = new ProducePlanBLL().GetByBatchNumber(model.BATCHNUMBER); if (plan != null) { model.FACTORYPID = plan.FACTORYPID; model.PRID = plan.PRID; } model.UPDATEUSER = this.LoginUser.UserID; model.UPDATETIME = DateTime.Now; result.Result = new ProduceTrackDAL().Update(model); result.IsSuccess = true; return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 插入信息(单表) /// </summary> /// <param name="">信息</param> /// <returns>插入行数</returns> public DataResult <int> Insert(ProduceTrack model) { DataResult <int> result = new DataResult <int>(); try { //基本信息 model.PID = Guid.NewGuid().ToString(); model.CREATEUSER = this.LoginUser.UserID; model.CREATETIME = DateTime.Now; model.UPDATEUSER = model.CREATEUSER; model.UPDATETIME = model.CREATETIME; //获取生产计划信息 ProducePlan plan = new ProducePlanBLL().GetByBatchNumber(model.BATCHNUMBER); if (plan != null) { model.FACTORYPID = plan.FACTORYPID; model.PRID = plan.PRID; } result.Result = new ProduceTrackDAL().Insert(model); result.IsSuccess = true; return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取信息 /// </summary> /// <param name="">条件</param> /// <returns>信息</returns> public ProduceTrack Get(ProduceTrack model) { try { return(new ProduceTrackDAL().Get(model)); } catch (Exception ex) { throw ex; } }
private void BindData(string id) { ProduceTrackBLL bll = null; ProduceTrack info = new ProduceTrack(); try { bll = BLLFactory.CreateBLL <ProduceTrackBLL>(); if (string.IsNullOrEmpty(id) == false) { info.PID = id; info = bll.Get(info); UIBindHelper.BindForm(this.Page, info); this.PNAME.Text = info.PNAME; this.CBNAME.Text = info.CBNAME; this.GXNAME.Text = info.GXNAME; this.hiID.Value = info.PID; this.HiCREATEUSER.Value = info.CREATEUSER; this.HiCREATETIME.Value = info.CREATETIME.ToString(); this.hiCB.Value = info.EQUID; this.hiGX.Value = info.WPID; this.hiPid.Value = info.PRODUCTIONID; this.WORKINGSTARTTIME.Value = info.WORKINGSTARTTIME.ToString(); if (info.WORKINGSTARTTIME != DateTime.MinValue) { this.StartTime.Text = info.WORKINGSTARTTIME.Hour + ":" + info.WORKINGSTARTTIME.Minute + ":" + info.WORKINGSTARTTIME.Second; this.CurrentTime.Text = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts2 = new TimeSpan(info.WORKINGSTARTTIME.Ticks); TimeSpan ts = ts1.Subtract(ts2).Duration(); this.SpendTime.Text = ts.Hours.ToString() + "小时" + ts.Minutes.ToString() + "分钟" + ts.Seconds.ToString() + "秒"; } else { this.StartTime.Text = ""; this.CurrentTime.Text = ""; this.SpendTime.Text = ""; } } else { info = new ProduceTrack(); } SetBtnState(); } catch (Exception ex) { throw ex; } }
/// <summary> /// 更新信息 /// </summary> /// <param name=""></param> /// <returns>更新行数</returns> public int Update(ProduceTrack model) { int count = 0; try { using (IDataSession session = AppDataFactory.CreateMainSession()) { //更新基本信息 count = session.Update <ProduceTrack>(model); } return(count); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取导出的数据 /// </summary> /// <param name="user">查询条件</param> /// <returns>数据</returns> public DataTable GetExportData(ProduceTrack model) { DataTable dt = null; string sql = null; List <DataParameter> parameters = new List <DataParameter>(); try { //构成查询语句 sql = this.GetQuerySql(model, ref parameters); using (IDataSession session = AppDataFactory.CreateMainSession()) { dt = session.GetTable(sql, parameters.ToArray()); dt.TableName = "EquipmentInfo"; } return(dt); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取查询语句 /// </summary> /// <param name="user">查询条件</param> /// <param name="parameters">参数</param> /// <returns>查询语句</returns> private string GetQuerySql(ProduceTrack condition, ref List <DataParameter> parameters) { StringBuilder sqlBuilder = new StringBuilder(); StringBuilder whereBuilder = new StringBuilder(); try { //构成查询语句 sqlBuilder.Append(@"SELECT t1.* FROM T_FP_PRODUCETRACK t1"); //查询条件 if (whereBuilder.Length > 0) { sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4)); } return(sqlBuilder.ToString()); } catch (Exception ex) { throw ex; } }
protected void btStart_Click(object sender, EventArgs e) { LoginInfo user = (Session["UserInfo"] as LoginInfo) as LoginInfo; ProduceTrack info = new ProduceTrack(); ProduceTrackBLL bll = null; try { UIBindHelper.BindModelByControls(this.Page, info); bll = BLLFactory.CreateBLL <ProduceTrackBLL>(); info.PRODUCTIONID = this.PRODUCTIONID.Value; if (this.hiID.Value == "") { info.PID = Guid.NewGuid().ToString(); info.STATUS = "0"; info.WPID = this.hiGX.Value; info.EQUID = this.hiCB.Value; info.WSID = this.hiGW.Value; info.FACTORYPID = user.OrgaID; info.WORKINGSTARTTIME = DateTime.Now; //校验是否跳序 string result = new ProcessCheckBLL().CheckSkipProcess(info.BATCHNUMBER, info.PRODUCTIONID, info.WPID); if (result != "") { ClientScript.RegisterStartupScript(this.GetType(), "myjs", "alert('" + result + "');", true); return; } bll.Insert(info); this.HiCREATEUSER.Value = info.CREATEUSER; this.HiCREATETIME.Value = info.CREATETIME.ToString(); } else { info.PID = this.hiID.Value; info.WORKINGSTARTTIME = DateTime.Now; info.STATUS = "0"; info.WPID = this.hiGX.Value; info.EQUID = this.hiCB.Value; info.WSID = this.hiGW.Value; info.CREATETIME = DateTime.Parse(this.HiCREATETIME.Value); info.CREATEUSER = this.HiCREATEUSER.Value; bll.Update(info); } BindData(info.PID); //获取产品信息 if (string.IsNullOrEmpty(this.BatchNumber.SelectedValue) == false) { ProducePlanBLL ppbll = BLLFactory.CreateBLL <ProducePlanBLL>(); ProductInfo result = ppbll.GetPNameByIDBatchNumber(this.BatchNumber.SelectedValue); this.PRODUCTIONID.Value = result.PID; this.PNAME.Text = result.PNAME; } this.hiID.Value = info.PID; //ClientScript.RegisterStartupScript(this.GetType(), "myjs", "window.location.href='MaterialTrace.aspx';", true); } catch (Exception ex) { throw ex; } }