Ejemplo n.º 1
0
        public void addInDecreaseHead(T_IndecreaseHead head)
        {
            Database db  = Dao.GetDatabase();
            string   sql = @"INSERT INTO [dbo].[Indecrease_head]
							   ([bill_no]
							   ,[itemID]
							   ,[customerID]
							   ,[customer]
							   ,[amount_all]
							   ,[agenter]
							   ,[agent_date]
							   ,[check_status])
						 VALUES
							   (@bill_no
							   ,@itemID
							   ,@customerID
							   ,@customer
							   ,@amount_all
							   ,@agenter
							   ,@agent_date
							   ,@check_status)"                            ;

            try
            {
                using (DbConnection cn = db.CreateConnection())
                {
                    DbCommand cmd = db.GetSqlStringCommand(sql);
                    db.AddInParameter(cmd, "@bill_no", DbType.String, head.BillNo);
                    db.AddInParameter(cmd, "@itemID", DbType.Int32, head.ItemID);
                    db.AddInParameter(cmd, "@customerID", DbType.Int32, head.CustomerID);
                    db.AddInParameter(cmd, "@customer", DbType.String, head.Customer);
                    db.AddInParameter(cmd, "@amount_all", DbType.Decimal, head.AmountAll);
                    db.AddInParameter(cmd, "@agenter", DbType.String, head.Agenter);
                    db.AddInParameter(cmd, "@agent_date", DbType.DateTime, head.AgentDate);
                    db.AddInParameter(cmd, "@check_status", DbType.Int32, head.CheckStatus);

                    db.ExecuteNonQuery(cmd);
                }
            }
            catch
            {
                throw new Exception("添加增减单表头数据失败,请检查人品");
            }
        }
Ejemplo n.º 2
0
    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 updateHead(T_IndecreaseHead item)
 {
     Manager.updateHead(item);
 }
    protected void add_Click(object sender, EventArgs e)
    {
        //表头
        T_IndecreaseHead head = new T_IndecreaseHead();

        head.AgentDate   = DateTime.Parse(agent_date.Text);
        head.BillNo      = bill_no.Text;
        head.Customer    = customer.Text;
        head.Agenter     = agent_name.Text;
        head.CheckStatus = 0;
        head.CurrencyID  = ddl_currency.SelectedValue;
        decimal             amount_all = 0;
        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;
        }
        //表体
        DataTable dt = DefineDataTableSchema(hfRptColumns.Value);

        foreach (RepeaterItem item in rptTest.Items)
        {
            DataRow newRow = dt.NewRow();

            string name = ((TextBox)item.FindControl("txt_name")).Text;
            if (string.IsNullOrEmpty(name))
            {
                //如果项号是空,则过滤此条记录
                continue;
            }
            string amount = ((TextBox)item.FindControl("txt_amount")).Text;
            if (string.IsNullOrEmpty(amount))
            {
                //如果项号是空,则过滤此条记录
                continue;
            }
            string apply_date = ((TextBox)item.FindControl("cb_apply_date")).Text;
            if (string.IsNullOrEmpty(apply_date))
            {
                //如果项号是空,则过滤此条记录
                continue;
            }
            string type = ((DropDownList)item.FindControl("ddl_type")).SelectedValue;
            if (string.IsNullOrEmpty(type))
            {
                //如果项号是空,则过滤此条记录
                continue;
            }
            newRow["g_no"]       = ((TextBox)item.FindControl("txt_g_no")).Text;
            newRow["name"]       = name;
            newRow["amount"]     = amount;
            newRow["apply_date"] = apply_date;
            newRow["type"]       = type;
            if (type == "R")
            {
                amount_all += Decimal.Parse(amount) * -1;
            }
            else
            {
                amount_all += Decimal.Parse(amount);
            }
            newRow["note"]    = ((TextBox)item.FindControl("txt_note")).Text;;
            newRow["bill_no"] = bill_no.Text;
            dt.Rows.Add(newRow);
        }

        head.AmountAll = amount_all;
        try
        {
            InDecreaseAdapter ida = new InDecreaseAdapter();
            ida.insertInDecreaseList(dt);
            ida.addInDecreaseHead(head);
            clean();
            Label1.Text = "哟,小伙子,不错,被你录入成功了";
        }
        catch (Exception ex)
        {
            Label1.Text = ex.Message;
        }
    }
 public void addInDecreaseHead(T_IndecreaseHead head)
 {
     Manager.addInDecreaseHead(head);
 }