/// <summary> /// 更新一条数据 /// </summary> public int Update(Model.Invoice_Model model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Stale_Invoice set "); strSql.Append("InvoiceNo=@InvoiceNo,"); strSql.Append("LTDName=@LTDName,"); strSql.Append("DemoName=@DemoName,"); strSql.Append("Money=@Money,"); strSql.Append("Invoicetime=@Invoicetime,"); strSql.Append("Payment=@Payment,"); strSql.Append("Status=@Status,"); strSql.Append("Handling=@Handling,"); strSql.Append("EmpName=@EmpName,"); strSql.Append("IsBank=@IsBank,"); strSql.Append("Remark=@Remark,"); strSql.Append("ContractNo=@ContractNo"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@InvoiceNo", SqlDbType.NVarChar, 100), new SqlParameter("@LTDName", SqlDbType.NVarChar, 100), new SqlParameter("@DemoName", SqlDbType.NVarChar, 100), new SqlParameter("@Money", SqlDbType.Decimal, 9), new SqlParameter("@Invoicetime", SqlDbType.DateTime), new SqlParameter("@Payment", SqlDbType.NVarChar, 50), new SqlParameter("@Status", SqlDbType.NVarChar, 50), new SqlParameter("@Handling", SqlDbType.NVarChar, 50), new SqlParameter("@EmpName", SqlDbType.NVarChar, 50), new SqlParameter("@IsBank", SqlDbType.NVarChar, 50), new SqlParameter("@Remark", SqlDbType.NVarChar, 100), new SqlParameter("@ContractNo", SqlDbType.NVarChar, 100) }; parameters[0].Value = model.ID; parameters[1].Value = model.InvoiceNo; parameters[2].Value = model.LTDName; parameters[3].Value = model.DemoName; parameters[4].Value = model.Money; parameters[5].Value = model.Invoicetime; parameters[6].Value = model.Payment; parameters[7].Value = model.Status; parameters[8].Value = model.Handling; parameters[9].Value = model.EmpName; parameters[10].Value = model.IsBank; parameters[11].Value = model.Remark; parameters[12].Value = model.ContractNo; return(DbHelperSQL.ExecuteCommand(strSql.ToString(), parameters)); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Invoice_Model GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,InvoiceNo,LTDName,DemoName,Money,Invoicetime,Payment,Status,Handling,EmpName,IsBank,Remark,ContractNo from Stale_Invoice "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Model.Invoice_Model model = new Model.Invoice_Model(); DataTable dt = DbHelperSQL.GetDateSet(strSql.ToString(), parameters); if (dt.Rows.Count > 0) { if (dt.Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[0]["ID"].ToString()); } model.InvoiceNo = dt.Rows[0]["InvoiceNo"].ToString(); model.LTDName = dt.Rows[0]["LTDName"].ToString(); model.DemoName = dt.Rows[0]["DemoName"].ToString(); if (dt.Rows[0]["Money"].ToString() != "") { model.Money = decimal.Parse(dt.Rows[0]["Money"].ToString()); } if (dt.Rows[0]["Invoicetime"].ToString() != "") { model.Invoicetime = DateTime.Parse(dt.Rows[0]["Invoicetime"].ToString()); } model.Payment = dt.Rows[0]["Payment"].ToString(); model.Status = dt.Rows[0]["Status"].ToString(); model.Handling = dt.Rows[0]["Handling"].ToString(); model.EmpName = dt.Rows[0]["EmpName"].ToString(); model.IsBank = dt.Rows[0]["IsBank"].ToString(); model.Remark = dt.Rows[0]["Remark"].ToString(); model.ContractNo = dt.Rows[0]["ContractNo"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Invoice_Model model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Stale_Invoice("); strSql.Append("InvoiceNo,LTDName,DemoName,Money,Invoicetime,Payment,Status,Handling,EmpName,IsBank,Remark,ContractNo)"); strSql.Append(" values ("); strSql.Append("@InvoiceNo,@LTDName,@DemoName,@Money,@Invoicetime,@Payment,@Status,@Handling,@EmpName,@IsBank,@Remark,@ContractNo)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@InvoiceNo", SqlDbType.NVarChar, 100), new SqlParameter("@LTDName", SqlDbType.NVarChar, 100), new SqlParameter("@DemoName", SqlDbType.NVarChar, 100), new SqlParameter("@Money", SqlDbType.Decimal, 9), new SqlParameter("@Invoicetime", SqlDbType.DateTime), new SqlParameter("@Payment", SqlDbType.NVarChar, 50), new SqlParameter("@Status", SqlDbType.NVarChar, 50), new SqlParameter("@Handling", SqlDbType.NVarChar, 50), new SqlParameter("@EmpName", SqlDbType.NVarChar, 50), new SqlParameter("@IsBank", SqlDbType.NVarChar, 50), new SqlParameter("@Remark", SqlDbType.NVarChar, 100), new SqlParameter("@ContractNo", SqlDbType.NVarChar, 100) }; parameters[0].Value = model.InvoiceNo; parameters[1].Value = model.LTDName; parameters[2].Value = model.DemoName; parameters[3].Value = model.Money; parameters[4].Value = model.Invoicetime; parameters[5].Value = model.Payment; parameters[6].Value = model.Status; parameters[7].Value = model.Handling; parameters[8].Value = model.EmpName; parameters[9].Value = model.IsBank; parameters[10].Value = model.Remark; parameters[11].Value = model.ContractNo; return(DbHelperSQL.ExecuteCommand(strSql.ToString(), parameters)); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(Model.Invoice_Model model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Invoice_Model model) { return(dal.Add(model)); }
/// <summary> /// 新增 /// </summary> /// <returns></returns> private bool AddInvoice() { FinanceManagerSys.Model.Invoice_Model model = new FinanceSys.FinanceManagerSys.Model.Invoice_Model(); FinanceManagerSys.BLL.InvoiceMX_BLL mx = new FinanceSys.FinanceManagerSys.BLL.InvoiceMX_BLL(); model.DemoName = this.txtDemoname.Text.Trim(); model.EmpName = this.cbxEmp.Text; model.Handling = this.txtHandling.Text.Trim(); model.InvoiceNo = this.txtInvoiceno.Text.Trim(); model.ContractNo = this.txtContractno.Text.Trim(); model.Invoicetime = DateTime.Now; model.LTDName = this.txtB.Text.Trim(); model.Money = decimal.Parse(this.txtInvoiceMoney.Text.Trim()); model.Payment = cbxPayment.Text; model.Remark = this.txtRemark.Text.Trim(); model.Status = this.cbxStatus.Text; model.IsBank = ""; int item = App_Code.Canshu.Id; if (invoicebll.GetIsCount(item)) { if (mx.Add(this.InvoiceMX()) > 0) { UpdateInvoice(); return(true); } else { return(false); } } else { //根据状态画图标开始 switch (cbxStatus.Text) { #region 未付 case "未付": PictureBox pi = new PictureBox(); pi.Image = global::FinanceSys.Properties.Resources.orange; pi.Location = new System.Drawing.Point(wi, hei); pi.Name = "pic1"; pi.Size = new System.Drawing.Size(35, 35); pi.TabIndex = 11; pi.TabStop = false; Label lb1 = new Label(); lb1.Text = "名称:" + this.txtB.Text.Trim(); lb1.Size = new System.Drawing.Size(35, 15); lb1.Location = new System.Drawing.Point(wi, hei + pi.Height + 3); Label lbl1 = new Label(); lbl1.Text = "金额:"; lbl1.Text += this.txtInvoiceMoney.Text.Trim(); lbl1.Size = new System.Drawing.Size(115, 15); lbl1.Location = new System.Drawing.Point(pi.Location.X, hei + pi.Height + 15 + lbl1.Height); this.dgvInfo.Controls.Add(lb1); this.dgvInfo.Controls.Add(lbl1); this.dgvInfo.Controls.Add(pi); if (wi + pi.Width >= this.groupBox2.Width - 100) { hei += 83; wi = 5; } else { wi += 50; } break; #endregion #region 未付完 case "未付完": PictureBox pi2 = new PictureBox(); pi2.Image = global::FinanceSys.Properties.Resources.yellow; pi2.Location = new System.Drawing.Point(wi, hei); pi2.Name = "pic2"; pi2.Size = new System.Drawing.Size(35, 35); pi2.TabIndex = 11; pi2.TabStop = false; Label lb12 = new Label(); lb12.Text = "名称:" + this.txtB.Text.Trim(); lb12.Size = new System.Drawing.Size(35, 15); lb12.Location = new System.Drawing.Point(wi, hei + pi2.Height + 3); Label lb2 = new Label(); lb2.Text = "金额:"; lb2.Text += this.txtInvoiceMoney.Text.Trim(); lb2.Size = new System.Drawing.Size(115, 15); lb2.Location = new System.Drawing.Point(pi2.Location.X, hei + pi2.Height + 15 + lb2.Height); this.dgvInfo.Controls.Add(lb12); this.dgvInfo.Controls.Add(lb2); this.dgvInfo.Controls.Add(pi2); if (wi + pi2.Width >= this.groupBox2.Width - 100) { hei += 83; wi = 5; } else { wi += 50; } break; #endregion #region 已付完 case "已付完": PictureBox pi3 = new PictureBox(); pi3.Image = (Image)global::FinanceSys.Properties.Resources.red; pi3.Location = new System.Drawing.Point(wi, hei); pi3.Name = "pic3"; pi3.Size = new System.Drawing.Size(35, 35); pi3.TabIndex = 11; pi3.TabStop = false; Label lb13 = new Label(); lb13.Text = "名称:" + this.txtB.Text.Trim(); lb13.Size = new System.Drawing.Size(35, 15); lb13.Location = new System.Drawing.Point(wi, hei + pi3.Height + 3); Label lb4 = new Label(); lb4.Text = "金额:"; lb4.Text += this.txtInvoiceMoney.Text.Trim(); lb4.Size = new System.Drawing.Size(115, 15); lb4.Location = new System.Drawing.Point(pi3.Location.X, hei + pi3.Height + 15 + lb4.Height); this.dgvInfo.Controls.Add(lb13); this.dgvInfo.Controls.Add(lb4); this.dgvInfo.Controls.Add(pi3); if (wi + pi3.Width >= this.groupBox2.Width - 100) { hei += 83; wi = 5; } else { wi += 50; } break; default: break; #endregion } if (invoicebll.Add(model) > 0) { mx.Add(this.InvoiceMX()); return(true); } else { return(false); } } }