Beispiel #1
0
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         string[]          estr    = e.CommandArgument.ToString().Split(',');
         string            bill_no = estr[0];
         int               g_no    = Convert.ToInt32(estr[1]);
         decimal           amount  = Decimal.Parse(estr[2]);
         string            type    = estr[3];
         InDecreaseAdapter ida     = new InDecreaseAdapter();
         try
         {
             updateHeadAmountAllForDeleteList(bill_no, amount, type);
             ida.delete(bill_no, g_no);
             GridView1.SelectedIndex = -1;
             GridViewBind();
             clean();
             Label1.Text = "删除成功";
         }
         catch (Exception ex)
         {
             Label1.Text = ex.Message;
         }
     }
 }
Beispiel #2
0
    private void setData(string id)
    {
        if (string.IsNullOrEmpty(id))
        {
            return;
        }
        InDecreaseAdapter ida  = new InDecreaseAdapter();
        DataSet           head = ida.getInDecreaseHeadByBillNo(id);

        lbl_customer.Text      = head.Tables[0].Rows[0]["customer"].ToString();
        lbl_indecrease_id.Text = id;
        if (!string.IsNullOrEmpty(head.Tables[0].Rows[0]["currencyID"].ToString()))
        {
            int           currency = Int32.Parse(head.Tables[0].Rows[0]["currencyID"].ToString());
            CommonAdapter ca       = new CommonAdapter();
            lbl_currency.Text = ca.getCurrencyByID(currency);
        }

        lbl_agenter.Text     = head.Tables[0].Rows[0]["agenter"].ToString();
        lbl_agente_date.Text = head.Tables[0].Rows[0]["agent_date"].ToString();

        DataSet list = ida.getInDecreaseInfoByBillNo(id);

        gridviewBind(list);
    }
Beispiel #3
0
    private void GridViewBind()
    {
        InDecreaseAdapter ida = new InDecreaseAdapter();
        DataSet           ds  = ida.getListsAll();

        show(ds);
    }
Beispiel #4
0
    protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            string receipt_id = e.CommandArgument.ToString();

            ReceiptAuditAdapter raa = new ReceiptAuditAdapter();
            InDecreaseAdapter   ida = new InDecreaseAdapter();
            DepositAdapter      da  = new DepositAdapter();

            try
            {
                DataSet ds = raa.getInDecreaseList(receipt_id);
                ida.updateHeadCheckStatus(ds);

                ds = raa.getDepositList(receipt_id);
                da.updateHeadCheckStatus(ds);



                raa.deleteToDone(receipt_id);
                raa.deleteReceipt(receipt_id);
                GridView3.SelectedIndex = -1;
                GridViewBind();

                Label1.Text = "删除成功";
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
            }
        }
    }
    private void GridViewBind(int id, int currencyID)
    {
        InDecreaseAdapter ida = new InDecreaseAdapter();
        DataSet           ds  = ida.getUnCheckInDecreaseLists(id, currencyID);

        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
    private string LoadLastBillNo()
    {
        //string search = "SKDJ" + DateTime.Now.Year.ToString().Substring(2, 2);
        string            search = DateTime.Now.ToString("yyyyMMdd");
        InDecreaseAdapter ida    = new InDecreaseAdapter();

        return(ida.getLastBillNo(search));
    }
Beispiel #7
0
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int       index       = GridView1.SelectedIndex;
        HyperLink thisData    = GridView1.SelectedRow.Cells[1].Controls[0] as HyperLink;
        string    str_bill_no = thisData.Text;

        bill_no.Text = str_bill_no;
        InDecreaseAdapter ida = new InDecreaseAdapter();

        try
        {
            DataSet ds = ida.getInDecreaseHeadByBillNo(str_bill_no);
            customer.Text   = ds.Tables[0].Rows[0]["customer"].ToString();
            agent_name.Text = ds.Tables[0].Rows[0]["agenter"].ToString();
            string str_agent_date = ds.Tables[0].Rows[0]["agent_date"].ToString();
            agent_date.Text            = DateTime.Parse(str_agent_date).ToString("yyyy-MM-dd HH:mm:ss");
            hdf_amount_all.Value       = ds.Tables[0].Rows[0]["amount_all"].ToString();
            ddl_currency.SelectedValue = ds.Tables[0].Rows[0]["currencyID"].ToString();
        }
        catch (Exception ex)
        {
            Label1.Text = ex.Message;
        }

        txt_g_no.Text    = GridView1.SelectedRow.Cells[2].Text;
        txt_name.Text    = GridView1.SelectedRow.Cells[3].Text;
        hdf_amount.Value = txt_amount.Text = GridView1.SelectedRow.Cells[4].Text;
        string typeName = GridView1.SelectedRow.Cells[5].Text;

        if (typeName == "扣    款")
        {
            ddl_type.SelectedValue = "R";
        }
        else
        {
            ddl_type.SelectedValue = "B";
        }

        if (ddl_type.SelectedValue == "R")
        {
            hdf_amount.Value = (Decimal.Parse(txt_amount.Text) * (-1)).ToString();
        }
        string str_apply_date = GridView1.SelectedRow.Cells[6].Text;

        cb_apply_date.Text = DateTime.Parse(str_apply_date).ToString("yyyy-MM-dd HH:mm:ss");
        txt_note.Text      = GridView1.SelectedRow.Cells[7].Text;
    }
Beispiel #8
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        InDecreaseAdapter ida = new InDecreaseAdapter();
        DataSet           ds;

        if (string.IsNullOrEmpty(query_bill_no.Text))
        {
            ds = ida.getListsAll();
        }
        else
        {
            ds = ida.getInDecreaseInfoByBillNo(query_bill_no.Text);
        }

        show(ds);
        clean();
    }
Beispiel #9
0
    protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            string[] args         = e.CommandArgument.ToString().Split(',');
            string   receipt_id   = args[0];
            string   receipt_type = args[1];

            ReceiptAuditAdapter raa = new ReceiptAuditAdapter();
            InDecreaseAdapter   ida = new InDecreaseAdapter();
            DepositAdapter      da  = new DepositAdapter();
            try
            {
                DataSet ds = raa.getInDecreaseList(receipt_id);
                ida.updateHeadCheckStatus(ds);

                ds = raa.getDepositList(receipt_id);
                if (receipt_type == "B")
                {
                    da.updateHeadIsPayed(ds);
                }
                else
                {
                    da.updateHeadCheckStatus(ds);//更新定金单的check_status值;
                }

                raa.deleteToDone(receipt_id);
                raa.deleteReceipt(receipt_id);
                GridView3.SelectedIndex = -1;
                GridViewBind();

                Label1.Text = "删除成功";
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
            }
        }
    }
Beispiel #10
0
    private void updateHeadAmountAllForDeleteList(string bill_no, decimal amount, string type)
    {
        InDecreaseAdapter ida        = new InDecreaseAdapter();
        DataSet           ds         = ida.getInDecreaseHeadByBillNo(bill_no);
        decimal           amount_all = Decimal.Parse(ds.Tables[0].Rows[0]["amount_all"].ToString());

        if (type == "R")
        {
            amount_all -= amount * -1;
        }
        else
        {
            amount_all -= amount;
        }
        if (amount_all == 0)
        {
            ida.deleteHead(bill_no);
        }
        else
        {
            ida.updateHeadAmountAll(bill_no, amount_all);
        }
    }
Beispiel #11
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;
        }
    }
    protected void updateUser_Click(object sender, EventArgs e)
    {
        Label1.Text = "";
        T_ReceiptHead head = new T_ReceiptHead();

        head.CustomerName = txt_customer.Text;
        if (!string.IsNullOrEmpty(head.CustomerName))
        {
            head.CustomerCode = getCusIDByName(head.CustomerName);
            if (string.IsNullOrEmpty(head.CustomerCode))
            {
                Label1.Text = "输入的公司名称不对,请输入关键字然后从下拉框中选择!";
                return;
            }
        }
        head.ReceiptId   = txt_recetpt_no.Text;
        head.ReceiptDate = DateTime.Parse(d_date.Text);
        head.ReceiptType = ddl_receipt_type.SelectedValue;
        head.AccountId   = ddl_account.SelectedValue;
        if (!String.IsNullOrEmpty(txt_amount.Text) && Decimal.Parse(txt_amount.Text) > 0)
        {
            head.Amount = Decimal.Parse(txt_amount.Text);
        }
        else
        {
            Label1.Text = "该收款单金额不能为0。";
            return;
        }
        head.Currency = ddl_currency.SelectedValue;
        if (!string.IsNullOrEmpty(txt_receipt_charge.Text))
        {
            head.ReceiptCharge = Decimal.Parse(txt_receipt_charge.Text);
        }
        head.FDeptID      = Int32.Parse(ddl_department.SelectedValue);
        head.FEmpID       = Int32.Parse(ddl_emp.SelectedValue);
        head.FPreparer    = Int32.Parse(ddl_preparer.SelectedValue);
        head.FChecker     = Int32.Parse(ddl_checker.SelectedValue);
        head.FCheckDate   = DateTime.Parse(check_date.Text);
        head.Note         = txt_note.Text;
        head.FCheckStatus = (int)2;
        head.AuditStatus  = 1;

        CommonAdapter        ca    = new CommonAdapter();
        List <T_ReceiptList> lists = new List <T_ReceiptList>();

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            T_ReceiptList list = new T_ReceiptList();
            list.ReceiptId = head.ReceiptId;
            list.ReceiptNo = Int32.Parse((GridView1.Rows[i].Cells[0].FindControl("lbl_gno") as Label).Text);
            string fbillno = (GridView1.Rows[i].Cells[1].FindControl("txt_bill_no") as TextBox).Text;
            if (string.IsNullOrEmpty(fbillno))
            {
                continue;
            }
            list.FBillNo             = fbillno;
            list.FDate               = DateTime.Parse((GridView1.Rows[i].Cells[2].FindControl("lbl_fdate") as Label).Text);
            list.FAmountFor          = Decimal.Parse((GridView1.Rows[i].Cells[3].FindControl("lbl_amountfor") as Label).Text);
            list.FReceiveAmountFor   = Decimal.Parse((GridView1.Rows[i].Cells[4].FindControl("lbl_freceiveamountfor") as Label).Text);
            list.FUnReceiveAmountFor = Decimal.Parse((GridView1.Rows[i].Cells[5].FindControl("lbl_funreceiveamountfor") as Label).Text);
            string fcheckamountfor = (GridView1.Rows[i].Cells[6].FindControl("txt_fcheckamountfor") as TextBox).Text;
            if (string.IsNullOrEmpty(fcheckamountfor))
            {
                Label1.Text = "核销金额不能为空";
                return;
            }
            list.FCheckAmountFor = Decimal.Parse(fcheckamountfor);
            list.FCurrencyID     = ca.getIDByCurrency((GridView1.Rows[i].Cells[7].FindControl("lbl_fcurrencyid") as Label).Text);
            list.FNote           = (GridView1.Rows[i].Cells[8].FindControl("txt_note") as TextBox).Text;
            if (list.FUnReceiveAmountFor - list.FCheckAmountFor == 0)
            {
                list.FCheckStatus = 2;
            }
            else
            {
                list.FCheckStatus = 1;
                head.FCheckStatus = 1;
            }
            lists.Add(list);
        }
        for (int i = 0; i < GridView2.Rows.Count; i++)
        {
            T_ReceiptList list = new T_ReceiptList();
            list.ReceiptId = head.ReceiptId;

            list.ReceiptNo = GridView1.Rows.Count + Int32.Parse((GridView2.Rows[i].Cells[0].FindControl("lbl_gno") as Label).Text);
            string indecreaseno = (GridView2.Rows[i].Cells[1].FindControl("txt_bill_no") as TextBox).Text;
            if (string.IsNullOrEmpty(indecreaseno))
            {
                continue;
            }
            list.IndecreaseNo = indecreaseno;
            list.FAmountFor   = Decimal.Parse((GridView2.Rows[i].Cells[3].FindControl("lbl_amount_all") as Label).Text);
            lists.Add(list);
        }
        List <T_ReceiptList> listsFromDeposit = new List <T_ReceiptList>();

        foreach (GridViewRow gvr in GridView3.Rows)
        {
            T_ReceiptList list = new T_ReceiptList();
            list.ReceiptId = head.ReceiptId;
            list.ReceiptNo = GridView1.Rows.Count + GridView2.Rows.Count + Int32.Parse((gvr.Cells[0].FindControl("lbl_gno") as Label).Text);
            string deposit_id = (gvr.Cells[1].FindControl("txt_deposit_id") as TextBox).Text;
            if (string.IsNullOrEmpty(deposit_id))
            {
                continue;
            }
            list.DepositId           = deposit_id;
            list.FDate               = DateTime.Parse((gvr.Cells[2].FindControl("lbl_agent_date") as Label).Text);
            list.FNote               = (gvr.Cells[9].FindControl("txt_note") as TextBox).Text;
            list.FCurrencyID         = ca.getIDByCurrency((gvr.Cells[7].FindControl("lbl_fcurrencyid") as Label).Text);
            list.FAmountFor          = Decimal.Parse((gvr.Cells[3].FindControl("lbl_amount_all") as Label).Text);
            list.FReceiveAmountFor   = Decimal.Parse((gvr.Cells[4].FindControl("lbl_freceiveamountfor") as Label).Text);
            list.FUnReceiveAmountFor = Decimal.Parse((gvr.Cells[5].FindControl("lbl_funreceiveamountfor") as Label).Text);
            string str_deposit_checkamountfor = (gvr.Cells[6].FindControl("txt_deposit_checkamountfor") as TextBox).Text;
            if (string.IsNullOrEmpty(str_deposit_checkamountfor))
            {
                Label1.Text = "核销金额不能为空";
                return;
            }
            list.FCheckAmountFor = Decimal.Parse(str_deposit_checkamountfor);
            if (list.FUnReceiveAmountFor - list.FCheckAmountFor == 0)
            {
                list.FCheckStatus = 2;
            }
            else
            {
                list.FCheckStatus = 1;
                head.FCheckStatus = 1;
            }
            listsFromDeposit.Add(list);
        }
        List <T_ReceiptList> addtodonelists   = addBillNoToDone(lists, head);
        List <T_ReceiptList> checkStatusLists = addInDecreaseNoToDone(lists);

        try
        {
            //保存数据
            ReceiptAuditAdapter raa = new ReceiptAuditAdapter();
            InDecreaseAdapter   ida = new InDecreaseAdapter();
            DepositAdapter      da  = new DepositAdapter();
            raa.addReceiptHead(head);
            raa.insertReceiptList(lists);
            raa.insertReceiptList(listsFromDeposit);

            //TODO:更新销售发票的check_status,增减单的check_status
            raa.addToDone(addtodonelists);               //把销售发票号加入已做列表中
            ida.updateHeadCheckStatus(checkStatusLists); //更新增减单的check_status值为2;
            if (ddl_receipt_type.SelectedValue == "B")
            {
                da.updateHeadIsPayed(listsFromDeposit);
            }
            else
            {
                da.updateHeadCheckStatus(listsFromDeposit);//更新定金单的check_status值;
            }
            Label1.Text = "哟,小伙子,不错,被你录入成功了";
        }
        catch (Exception ex)
        {
            Label1.Text = ex.Message;
        }
    }
    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;
        }
    }