/// <summary> /// 插入信息(单表) /// </summary> /// <param name="">信息</param> /// <returns>插入行数</returns> public DataResult <int> Insert(WHQualityCheck model) { DataResult <int> result = new DataResult <int>(); try { //基本信息 model.ID = Guid.NewGuid().ToString(); model.BillNO = this.GetNewBillNO(); model.CREATEUSER = this.LoginUser.UserID; model.CREATETIME = DateTime.Now; model.UPDATEUSER = model.CREATEUSER; model.UPDATETIME = model.CREATETIME; if (ExistsBillNO(model)) { result.Msg = "质检单号已存在"; result.Result = -1; return(result); } result.Result = new QualityCheckDAL().Insert(model); result.IsSuccess = true; return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 更新信息 /// </summary> /// <param name=""></param> /// <returns>更新行数</returns> public int Update(WHQualityCheck model) { int count = 0; string sql = "delete from T_WH_QualityCheckResult where CheckID = @CheckID"; try { using (IDataSession session = AppDataFactory.CreateMainSession()) { session.OpenTs(); count = session.Update <WHQualityCheck>(model); session.ExecuteSql(sql, new DataParameter("CheckID", model.ID)); foreach (WHQualityCheckResult detail in model.QualityCheckResults) { detail.ID = Guid.NewGuid().ToString(); detail.CheckID = model.ID; session.Insert <WHQualityCheckResult>(detail); } session.CommitTs(); } return(count); } catch (Exception ex) { throw ex; } }
/// <summary> /// 插入信息(单表) /// </summary> /// <param name="">信息</param> /// <returns>插入行数</returns> public int Insert(WHQualityCheck model) { int count = 0; try { using (IDataSession session = AppDataFactory.CreateMainSession()) { session.OpenTs(); //插入基本信息 count = session.Insert <WHQualityCheck>(model); foreach (WHQualityCheckResult detail in model.QualityCheckResults) { detail.ID = Guid.NewGuid().ToString(); detail.CheckID = model.ID; session.Insert <WHQualityCheckResult>(detail); } session.CommitTs(); } return(count); } catch (Exception ex) { throw ex; } }
private void BindData() { string id = Request.QueryString["id"]; QualityCheckBLL bll = null; WHQualityCheck info = new WHQualityCheck(); DataGridResult <WHQualityCheckResult> pList = new DataGridResult <WHQualityCheckResult>(); try { bll = BLLFactory.CreateBLL <QualityCheckBLL>(); int seq = 1; if (string.IsNullOrEmpty(id) == false) { info.ID = id; info = bll.Get(info); UIBindHelper.BindForm(this.Page, info); if (info.CheckResult == "0") { RB1.Checked = true; } else { RB2.Checked = true; } this.BillNoList.Items.Add(new ListItem(info.InStockBillNo, info.BillID)); this.BillNoList.SelectedValue = info.BillID; this.BillNoList.Enabled = false; this.hiID.Value = info.ID; this.HiCREATEUSER.Value = info.CREATEUSER; this.HiCREATETIME.Value = info.CREATETIME.ToString(); List <WHQualityCheckResult> list = bll.GetResultList(id); foreach (WHQualityCheckResult detail in list) { detail.DeleteAction = "deleteF(\'" + detail.FileName + "\')"; detail.DetailAction = "viewF(\'" + detail.FileName + "\')"; detail.SEQ = seq++; } pList.Total = list.Count; pList.Rows = list; } else { info = new WHQualityCheck(); this.BillNO.Text = bll.GetNewBillNO(); info.CheckPerson = GetLoginInfo().UserName; pList.Total = 0; pList.Rows = new List <WHQualityCheckResult>(); UIBindHelper.BindForm(this.Page, info); } this.hiPList.Value = pList.GetJsonSource(); } catch (Exception ex) { throw ex; } }
/// <summary> /// 判断单号是否存在 /// </summary> /// <param name="info"></param> /// <returns>true:已存在;fasel:不存在。</returns> public bool ExistsBillNO(WHQualityCheck model) { try { return(new QualityCheckDAL().ExistsBillNO(model)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取信息 /// </summary> /// <param name="">条件</param> /// <returns>信息</returns> public WHQualityCheck Get(WHQualityCheck model) { try { return(new QualityCheckDAL().Get(model)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 删除信息 /// </summary> /// <param name="">主键串</param> /// <returns>删除个数</returns> public int Delete(WHQualityCheck model) { try { return(new QualityCheckDAL().Delete(model)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取信息 /// </summary> /// <param name="">条件</param> /// <returns>*信息</returns> public WHQualityCheck Get(WHQualityCheck model) { try { using (IDataSession session = AppDataFactory.CreateMainSession()) { //获取信息 model = session.Get <WHQualityCheck>(model); } return(model); } catch (Exception ex) { throw ex; } }
/// <summary> /// 删除信息 /// </summary> /// <param name=""></param> /// <returns>删除个数</returns> public int Delete(WHQualityCheck model) { int count = 0; try { using (IDataSession session = AppDataFactory.CreateMainSession()) { //删除基本信息 count = session.Delete <WHQualityCheck>(model); //删除明细信息 string sql = "DELETE FROM T_WH_QualityCheckResult WHERE CheckID = @CheckID"; session.ExecuteSql(sql, new DataParameter("CheckID", model.ID)); } return(count); } catch (Exception ex) { throw ex; } }
/// <summary> /// 更新信息 /// </summary> /// <param name="">信息</param> /// <returns>更新行数</returns> public DataResult <int> Update(WHQualityCheck model) { DataResult <int> result = new DataResult <int>(); try { if (ExistsBillNO(model)) { result.Msg = "质检单号已存在"; result.Result = -1; return(result); } model.UPDATEUSER = this.LoginUser.UserID; result.Result = new QualityCheckDAL().Update(model); result.IsSuccess = true; return(result); } catch (Exception ex) { throw ex; } }
protected void btSave_Click(object sender, EventArgs e) { WHQualityCheck info = new WHQualityCheck(); QualityCheckBLL bll = null; try { UIBindHelper.BindModelByControls(this.Page, info); info.BillID = this.BillNoList.SelectedValue; info.InStockBillNo = this.BillNoList.SelectedItem.Text; info.QualityCheckResults = LAF.Common.Serialization.JsonConvertHelper.DeserializeObject <List <WHQualityCheckResult> >(this.hiPList.Value); bll = BLLFactory.CreateBLL <QualityCheckBLL>(); if (RB1.Checked) { info.CheckResult = "0"; } else { info.CheckResult = "1"; } if (this.hiID.Value == "") { bll.Insert(info); } else { info.CREATEUSER = this.HiCREATEUSER.Value; info.CREATETIME = DateTime.Parse(this.HiCREATETIME.Value); info.ID = this.hiID.Value; bll.Update(info); } ClientScript.RegisterStartupScript(this.GetType(), "myjs", "parent.refreshData();parent.closeAppWindow1();", true); } catch (Exception ex) { throw ex; } }
/// <summary> /// 判断单号是否存在 /// </summary> /// <param name="info"></param> /// <returns>true:已存在;fasel:不存在。</returns> public bool ExistsBillNO(WHQualityCheck model) { StringBuilder sqlBuilder = new StringBuilder(); StringBuilder whereBuilder = new StringBuilder(); List <DataParameter> parameters = new List <DataParameter>(); int count = 0; try { sqlBuilder.Append("SELECT COUNT(0) FROM T_WH_QualityCheck"); whereBuilder.Append(" AND ID <> @ID "); parameters.Add(new DataParameter { ParameterName = "ID", DataType = DbType.String, Value = model.ID }); if (!string.IsNullOrEmpty(model.BillNO)) { whereBuilder.Append(" AND BillNO = @BillNO "); parameters.Add(new DataParameter { ParameterName = "BillNO", DataType = DbType.String, Value = model.BillNO }); } if (whereBuilder.Length > 0) { sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4)); } using (IDataSession session = AppDataFactory.CreateMainSession()) { count = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(), parameters.ToArray())); } return(count > 0); } catch (Exception ex) { throw ex; } }