/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BBackBillData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into BBackBill("); strSql.Append(@"backBillNo,financeBillNo,custNo,materialNo,backDt,mark,isrtEmpId,isrtDt,updtEmpId,updtDt, commitEmpId,commitDt,instantState)"); strSql.Append(" values ("); strSql.Append(@"@backBillNo,@financeBillNo,@custNo,@materialNo,@backDt,@mark,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt, @commitEmpId,@commitDt,@instantState)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@backBillNo", SqlDbType.VarChar,20), new SqlParameter("@financeBillNo", SqlDbType.VarChar,20), new SqlParameter("@custNo", SqlDbType.VarChar,20), new SqlParameter("@materialNo", SqlDbType.VarChar,20), new SqlParameter("@backDt", SqlDbType.DateTime), new SqlParameter("@mark", SqlDbType.NVarChar,500), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime), new SqlParameter("@commitEmpId", SqlDbType.Int), new SqlParameter("@commitDt", SqlDbType.DateTime), new SqlParameter("@instantState", SqlDbType.NVarChar,20) }; parameters[0].Value = model.backBillNo; parameters[1].Value = model.financeBillNo; parameters[2].Value = model.custNo; parameters[3].Value = model.materialNo; parameters[4].Value = model.backDt == string.Empty ? null : model.backDt; parameters[5].Value = model.mark; parameters[6].Value = model.isrtEmpId; parameters[7].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[8].Value = model.updtEmpId; parameters[9].Value = model.updtDt == string.Empty ? null : model.updtDt; parameters[10].Value = model.commitEmpId; parameters[11].Value = model.commitDt == string.Empty ? null : model.commitDt; parameters[12].Value = model.instantState; int id = 0; try { object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ret != null && ret != DBNull.Value) { id = Convert.ToInt32(ret); } } catch (Exception ex) { throw ex; } return id; }
//***************************************************************************** //do it later do it later do it later //***************************************************************************** /// <summary> /// 保存退货单信息 /// </summary> /// <param name="dtBox">退货箱</param> /// <param name="strFinanceBillNo">采购订单编号</param> /// <param name="strCustNo">供应商编码</param> /// <param name="strMaterialNo">物料编码</param> /// <returns></returns> public bool SaveRecord(DataTable dtBox, string strFinanceBillNo, string strCustNo, string strMaterialNo,string checkRemark) { bool ret = false; BBackDetailBB backDetailBB = new BBackDetailBB(this.connection); SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSave"); this.backBillBB.Transaction = trans; backDetailBB.Transaction = trans; } else { this.backBillBB.Transaction = this.transaction; backDetailBB.Transaction = this.transaction; } BBackBillData backBillModel = new BBackBillData(); BBackDetailData backDetailModel = new BBackDetailData(); //保存退货单信息 backBillModel.backBillNo = this.backBillBB.GetCurrentBackBillNoByPreBillNo();//退货单编号 backBillModel.financeBillNo = strFinanceBillNo;//采购订单号 backBillModel.custNo = strCustNo;//供应商 backBillModel.materialNo = strMaterialNo;//物料编号 backBillModel.backDt = System.DateTime.Today.ToString();//退货日期 backBillModel.isrtDt = System.DateTime.Now.ToString();//添加时间 backBillModel.isrtEmpId = this.empId;//添加人 backBillModel.instantState = "01";//状态:01 未提交 //2015-07-28 修改 增加质检的remark //this.backBillBB.AddRecord(backBillModel); this.backBillBB.AddRecordWihtRemark(backBillModel, checkRemark); //保存退货单明细信息 foreach (DataRow dataRow in dtBox.Rows) { backDetailModel = new BBackDetailData(); backDetailModel.backBillNo = backBillModel.backBillNo;//退货单编号 backDetailModel.boxNo = dataRow["boxNo"].ToString();//箱号 backDetailModel.backNum = Convert.ToInt32(dataRow["num"]);//退货数量 backDetailBB.AddRecord(backDetailModel); } if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSave"); throw ex; } finally { backDetailBB.Dispose(); } return ret; }
/// <summary> /// 修改退货单信息 /// 2015-07-28 新增修改remark的功能 /// </summary> /// <param name="backBillModel">备货单实例</param> /// <param name="dtBox">退货箱</param> /// <returns></returns> public bool ModityRecord(BBackBillData backBillModel, DataTable dtBox,string fukingbuyerRemark) { bool ret = false; BBackDetailBB backDetailBB = new BBackDetailBB(this.connection); SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSave"); this.backBillBB.Transaction = trans; backDetailBB.Transaction = trans; } else { this.backBillBB.Transaction = this.transaction; backDetailBB.Transaction = this.transaction; } BBackDetailData backDetailModel = new BBackDetailData(); //保存退货单信息 //2015-07-28修改 // this.backBillBB.ModifyRecord(backBillModel); this.backBillBB.ModifyRecord(backBillModel,fukingbuyerRemark); //保存退货单明细信息 foreach (DataRow dataRow in dtBox.Rows) { if (Convert.ToBoolean(dataRow["isDel"]) == true) { backDetailBB.DeleteRecord(Convert.ToInt32(dataRow["id"])); } } if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSave"); throw ex; } finally { backDetailBB.Dispose(); } return ret; }
/// <summary> /// 更新一条"退货单"信息 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BBackBillData model) { bool ret = false; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransModify"); this.backBillBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } this.backBillBB.ModifyRecord(model); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = model.id.ToString(); operatDiaryData.operateContent = "退货单修改一条id为“" + model.id.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransModify"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "退货单修改记录“" + model.id.ToString() + "”时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return ret; }
/// <summary> /// 增加一条"退货单"信息 /// </summary> /// <param name="model">model</param> public int AddRecord(BBackBillData model) { int id = 0; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransAdd"); this.backBillBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } id = this.backBillBB.AddRecord(model); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = id.ToString(); operatDiaryData.operateContent = "退货单增加一条id为“" + id.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransAdd"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "退货单增加记录时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return id; }
/// <summary> /// 数据保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { BBackBillData model = new BBackBillData(); BBackBillBB backBillBB = new BBackBillBB(); BBackBillBC backBillBC = new BBackBillBC(); try { if (this.State == "2") { model = backBillBB.GetModel(this.IdValue); model.updtDt = DateTime.Now.ToString(); model.updtEmpId = this.currentUser.empId; model.instantState = "03";//采购确认后状态改为03 if (backBillBC.ModityRecord(model, this.dtDetail, mark.Text)) { //保存的时候 将保存的信息 //保存信息 if (backBillBB.InsertToNotice(this.lbBackBillNo.Text.ToString(), this.currentUser.empId, txtCustAddress.Text.Trim(), txtCustPerson.Text.Trim(), this.txtPhone.Text.Trim(), this.txtMobile.Text.Trim())) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"采购确认退货单成功\");", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"采购确认退货单失败\");", true); return; } } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"采购确认退货单失败\");", true); return; } mark.Text = ""; } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { backBillBB.Dispose(); backBillBC.Dispose(); } Response.Redirect("BBackBillListBuyer.aspx?itemno=" + this.itemNo + "&pTypeNo=main", false); }
public bool ModifyRecord(BBackBillData model,string fukingbuyerRemark) { return this.backBillDB.ModifyRecord(model,fukingbuyerRemark); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BBackBillData model) { return this.backBillDB.ModifyRecord(model); }
/// <summary> /// 2015-07-28 joey 修改质检单据功能 增加备注功能 /// </summary> /// <param name="model"></param> /// <param name="checkRemark"></param> /// <returns></returns> public int AddRecordWihtRemark(BBackBillData model,string checkRemark) { return this.backBillDB.AddRecordWithMark(model,checkRemark); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BBackBillData model) { return this.backBillDB.AddRecord(model); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BBackBillData model,string fuckingbuyerRemark) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update BBackBill set "); strSql.Append("backBillNo=@backBillNo,"); strSql.Append("financeBillNo=@financeBillNo,"); strSql.Append("custNo=@custNo,"); strSql.Append("materialNo=@materialNo,"); strSql.Append("backDt=@backDt,"); strSql.Append("mark=@mark,"); strSql.Append("isrtEmpId=@isrtEmpId,"); strSql.Append("isrtDt=@isrtDt,"); strSql.Append("updtEmpId=@updtEmpId,"); strSql.Append("updtDt=@updtDt,"); strSql.Append("commitEmpId=@commitEmpId,"); strSql.Append("commitDt=@commitDt,"); strSql.Append("instantState=@instantState,"); strSql.Append("buyerRemark=@buyerRemark"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@backBillNo", SqlDbType.VarChar,20), new SqlParameter("@financeBillNo", SqlDbType.VarChar,20), new SqlParameter("@custNo", SqlDbType.VarChar,20), new SqlParameter("@materialNo", SqlDbType.VarChar,20), new SqlParameter("@backDt", SqlDbType.DateTime), new SqlParameter("@mark", SqlDbType.NVarChar,500), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime), new SqlParameter("@commitEmpId", SqlDbType.Int), new SqlParameter("@commitDt", SqlDbType.DateTime), new SqlParameter("@instantState", SqlDbType.NVarChar,20), new SqlParameter("@buyerRemark", SqlDbType.NVarChar,100) }; parameters[0].Value = model.id; parameters[1].Value = model.backBillNo; parameters[2].Value = model.financeBillNo; parameters[3].Value = model.custNo; parameters[4].Value = model.materialNo; parameters[5].Value = model.backDt == string.Empty ? null : model.backDt; parameters[6].Value = model.mark; parameters[7].Value = model.isrtEmpId; parameters[8].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[9].Value = model.updtEmpId; parameters[10].Value = model.updtDt == string.Empty ? null : model.updtDt; parameters[11].Value = model.commitEmpId; parameters[12].Value = model.commitDt == string.Empty ? null : model.commitDt; parameters[13].Value = model.instantState; parameters[14].Value = fuckingbuyerRemark; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// 得到一个model /// </summary> /// <param name="id">主键值</param> /// <returns>model</returns> public BBackBillData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select id,backBillNo,financeBillNo,custNo,materialNo,backDt,mark,isrtEmpId,isrtDt,updtEmpId,updtDt, commitEmpId,commitDt,instantState from BBackBill"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; BBackBillData model = new BBackBillData(); DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; if (row["id"] != DBNull.Value) { model.id = Convert.ToInt32(row["id"]); } if (row["backBillNo"] != DBNull.Value) { model.backBillNo = Convert.ToString(row["backBillNo"]); } if (row["financeBillNo"] != DBNull.Value) { model.financeBillNo = Convert.ToString(row["financeBillNo"]); } if (row["custNo"] != DBNull.Value) { model.custNo = Convert.ToString(row["custNo"]); } if (row["materialNo"] != DBNull.Value) { model.materialNo = Convert.ToString(row["materialNo"]); } if (row["backDt"] != DBNull.Value) { model.backDt = Convert.ToString(row["backDt"]); } if (row["mark"] != DBNull.Value) { model.mark = Convert.ToString(row["mark"]); } if (row["isrtEmpId"] != DBNull.Value) { model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]); } if (row["isrtDt"] != DBNull.Value) { model.isrtDt = Convert.ToString(row["isrtDt"]); } if (row["updtEmpId"] != DBNull.Value) { model.updtEmpId = Convert.ToInt32(row["updtEmpId"]); } if (row["updtDt"] != DBNull.Value) { model.updtDt = Convert.ToString(row["updtDt"]); } if (row["commitEmpId"] != DBNull.Value) { model.commitEmpId = Convert.ToInt32(row["commitEmpId"]); } if (row["commitDt"] != DBNull.Value) { model.commitDt = Convert.ToString(row["commitDt"]); } if (row["instantState"] != DBNull.Value) { model.instantState = Convert.ToString(row["instantState"]); } return model; } else { return null; } }
/// <summary> /// 数据保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { BBackBillData model = new BBackBillData(); BBackBillBB backBillBB = new BBackBillBB(); BBackBillBC backBillBC = new BBackBillBC(); try { if (this.State == "2") { model = backBillBB.GetModel(this.IdValue); model.updtDt = DateTime.Now.ToString(); model.updtEmpId = this.currentUser.empId; backBillBC.ModityRecord(model, this.dtDetail); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { backBillBB.Dispose(); backBillBC.Dispose(); } Response.Redirect("BBackBillList.aspx?itemno=" + this.itemNo + "&pTypeNo=main", false); }