public void updateList(T_IndecreaseList item) { Database db = Dao.GetDatabase(); string sql = @"UPDATE [dbo].[Indecrease_list] SET [amount] = @amount ,[name] = @NAME ,[type] = @TYPE ,[apply_date] = @apply_date ,[note] = @note WHERE [bill_no] = @bill_no AND [g_no] = @g_no " ; using (DbConnection cn = db.CreateConnection()) { try { DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@amount", DbType.Decimal, item.Amount); db.AddInParameter(cmd, "@NAME", DbType.String, item.Name); db.AddInParameter(cmd, "@TYPE", DbType.String, item.Type); db.AddInParameter(cmd, "@apply_date", DbType.DateTime, item.ApplyDate); db.AddInParameter(cmd, "@note", DbType.String, item.Note); db.AddInParameter(cmd, "@bill_no", DbType.String, item.BillNo); db.AddInParameter(cmd, "@g_no", DbType.Int32, item.GNo); db.ExecuteNonQuery(cmd); } catch { throw new Exception("更新增减单表体数据失败,请检查人品"); } } }
protected void btnSave_Click(object sender, EventArgs e) { int index = GridView1.SelectedIndex; if (index < 0) { Label1.Text = "请先点击某行的编辑按钮"; return; } T_IndecreaseHead head = new T_IndecreaseHead(); head.BillNo = bill_no.Text.Trim(); head.Customer = customer.Text; head.CurrencyID = ddl_currency.SelectedValue; ReceiptAuditAdapter raa = new ReceiptAuditAdapter(); DataSet ds = raa.getCustInfoByName(head.Customer); if (ds.Tables[0].Rows.Count > 0) { head.CustomerID = Int32.Parse(ds.Tables[0].Rows[0]["FNumber"].ToString()); head.ItemID = Int32.Parse(ds.Tables[0].Rows[0]["FItemID"].ToString()); } else { Label1.Text = "客户姓名请输入关键字后从下拉框选择!"; return; } head.AgentDate = DateTime.Parse(agent_date.Text); head.Agenter = agent_name.Text; T_IndecreaseList list = new T_IndecreaseList(); list.BillNo = bill_no.Text.Trim(); list.GNo = Int32.Parse(txt_g_no.Text); list.Type = ddl_type.SelectedValue; list.Note = txt_note.Text; list.Name = txt_name.Text; list.Amount = Decimal.Parse(txt_amount.Text); list.ApplyDate = DateTime.Parse(cb_apply_date.Text); if (list.Type == "R") { head.AmountAll = Decimal.Parse(hdf_amount_all.Value) - Decimal.Parse(hdf_amount.Value) + Decimal.Parse(txt_amount.Text) * -1; } else { head.AmountAll = Decimal.Parse(hdf_amount_all.Value) - Decimal.Parse(hdf_amount.Value) + Decimal.Parse(txt_amount.Text); } InDecreaseAdapter ida = new InDecreaseAdapter(); try { ida.updateHead(head); ida.updateList(list); GridView1.SelectedIndex = -1; GridViewBind(); clean(); Label1.Text = "更新成功"; } catch (Exception ex) { Label1.Text = ex.Message; } }
public void updateList(T_IndecreaseList item) { Manager.updateList(item); }