/// <summary>
    /// 删除
    /// 2015-07-28 新增删除退货单明细的功能 删除备货单的时候 重新处理
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        BBackBillBB backBillBB = new BBackBillBB();
        BBackBillBC backBillBC = new BBackBillBC();

        BBackDetailBB backDetailBB = new BBackDetailBB();

        try
        {
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    int id = int.Parse(chkId.ValidationGroup);
                    string strBackBillNo = this.grid.DataKeys[gvrow.RowIndex]["backBillNo"].ToString();
                    BBackBillData backBillModel = backBillBB.GetModel(Convert.ToInt32(id));

                    if (backBillModel.instantState != "01")
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条未提交退货单记录!\");", true);
                        return;
                    }
                    else
                    {
                        retChecked = true;
                        backBillBC.DeleteRecord(id, "");
                        backDetailBB.DeleteRecord(strBackBillNo);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            backBillBB.Dispose();
            backBillBC.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
    /// <summary>
    /// 生成退货单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCreateBackBill_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(mark.Text))
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"退货原因没有编写!\");", true);
            return;
        }
        BBackBillBC backBillBC = new BBackBillBC();

        try
        {
            this.dtBox.Clear();//清空数据
            string strFinanceBillNo = "", strCustNo = "", strMaterialNo = "";
            string checkremark = "";//质检remark输入
            checkremark = mark.Text.Trim();//输入质检输入的问题
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    DataRow myDataRow = null;
                    string strBoxNo = "";
                    int num = 0;

                    //判断选择记录是否是同一采购订单同一物料
                    if (strFinanceBillNo != "" && strFinanceBillNo != this.grid.DataKeys[gvrow.RowIndex]["financeBillNo"].ToString()
                        && strMaterialNo != "" && strMaterialNo != this.grid.DataKeys[gvrow.RowIndex]["materialNo"].ToString())
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条相同采购订单的相同物料!\");", true);
                        return;
                    }

                    if (strFinanceBillNo == "")
                    {
                        strFinanceBillNo = this.grid.DataKeys[gvrow.RowIndex]["financeBillNo"].ToString();//采购订单编号
                        strCustNo = this.grid.DataKeys[gvrow.RowIndex]["custNo"].ToString();//供应商编号
                        strMaterialNo = this.grid.DataKeys[gvrow.RowIndex]["materialNo"].ToString();//物料编号
                    }

                    strBoxNo = chkId.ValidationGroup.ToString();//箱号
                    num = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["leavingNum"]);//退货数量

                    //添加一行
                    myDataRow = this.dtBox.NewRow();

                    myDataRow["boxNo"] = strBoxNo;
                    myDataRow["num"] = num;

                    this.dtBox.Rows.Add(myDataRow);
                }
            }

            if (this.dtBox.Rows.Count > 0)
            {
                backBillBC.EmpID = this.currentUser.empId;

                //保存退货信息
                backBillBC.SaveRecord(this.dtBox, strFinanceBillNo, strCustNo, strMaterialNo,checkremark);

                mark.Text = "";//保存后清除数据
                this.dtBox.Clear();
                this.BindGrid();

            }
            else
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条记录!\");", true);
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            backBillBC.Dispose();
        }
    }
    /// <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);
    }
Exemplo n.º 4
0
    /// <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);
    }