protected void Page_Load(object sender, EventArgs e)
        {
            Session["songhuodan"] = "1";
            if (!IsPostBack)
            {
                if (Session["SendList"] != null)
                {
                    List<PrevProductMOD> list = (List<PrevProductMOD>)Session["SendList"];

                    List<PrevProductMOD> newList = new List<PrevProductMOD>();
                    foreach (var m in list)
                    {
                        if (m.ProNum != "" && m.ProNum != "0")
                        {
                            newList.Add(m);
                        }
                    }

                    Repeater1.DataSource = newList;
                    Repeater1.DataBind();
                    rptPro.DataSource = newList;
                    rptPro.DataBind();
                }
                if (Request.QueryString["orderNum"] != null && Request.QueryString["orderNum"].ToString() != "")
                {
                    orderNum = Request.QueryString["orderNum"].ToString();
                    lblOrderNum.Text = orderNum;
                }
                if (Request.QueryString["sendTime"] != null && Request.QueryString["sendTime"].ToString() != "")
                {
                    lblPrintTime.Value = Request.QueryString["sendTime"].ToString();

                }
                if (Request.QueryString["customerNo"] != null && Request.QueryString["customerNo"].ToString() != "")
                {
                    string customNum = Request.QueryString["customerNo"].ToString();
                    CustomerManageMod mod = CustomerManageBLL.GetcustomerByid(customNum);
                    if (mod != null)
                    {
                        using (var db = new Web.Model.OrderPrintEntities())
                        {
                            var dtl = db.SendDetail.OrderByDescending(r => r.sendId).FirstOrDefault(r => r.orderNum == orderNum);
                            if (dtl != null && !string.IsNullOrEmpty(dtl.PrintCompanyName))
                            {
                                txtCompanyName.Text = dtl.PrintCompanyName;
                            }
                            else
                            {
                                txtCompanyName.Text = mod.CompanyName;
                            }
                        }
                        if (mod.IsShowPrice == 0)   //显示
                        {
                            div1.Visible = false;
                            div2.Visible = true;
                        }
                        else   //不显示
                        {
                            div1.Visible = true;
                            div2.Visible = false;
                        }
                    }
                    else
                    {
                        div1.Visible = true;
                        div2.Visible = false;
                    }
                }
                //产品型号
                if (Request.QueryString["proType"] != null && Request.QueryString["proType"].ToString() != "")
                {
                    proType = Request.QueryString["proType"].ToString();
                }
                //打印时间
                //  lblPrintTime.Value = DateTime.Now.ToShortDateString();

            }
        }
Example #2
0
    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Save_Click(object sender, EventArgs e)
    {
        try
        {

            bool real = true;
            //修改订单基本信息
            if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != "")
            {
                string orderNum = Request.QueryString["id"].ToString();
                int id;
                var db = new Web.Model.OrderPrintEntities();
                if (Int32.TryParse(Request.QueryString["id"], out id))
                {
                    orderNum = db.proOrders.Where(r => r.orderId == id).FirstOrDefault().orderNum;
                }

                //加载订单基本信息
                orderMod = ProOrdersBLL.GetModel(orderNum);
                orderMod.customManager = txtcustomManager.Text.Trim();
                orderMod.customOrderNum = txtcustomOrderNum.Text.Trim();
                orderMod.customWLBH = "";// txtcustomWLBH.Text.Trim();
                orderMod.heTongNum = txtheTongNum.Text.Trim();
                orderMod.remark = txtremark.Text.Trim();
                orderMod.UpdateTime = DateTime.Now;
                orderMod.FaPiaoDanhao = "";
                orderMod.ChengShuiHao = "";
                orderMod.Remark1 = "";
                orderMod.EditUser = UserInfo.UserId;
                orderMod.IsTiXing = 0;
                orderMod.ShuRuXianchang = "";// txtshuRuXianchang.Text.Trim();
                orderMod.ShuChuXianchang = "";// txtshuChuXianchang.Text.Trim();

                var intorderDetailId = id;
                var gt_order = db.proOrders.FirstOrDefault(r => r.orderId == orderMod.orderId);
                gt_order.发货状态 = rbl发货状态.SelectedValue;
                db.SaveChanges();

                //if (txtYijiekuanMoney.Text.Trim() != "")
                //{
                //    orderMod.YijiekuanMoney = Convert.ToDecimal(txtYijiekuanMoney.Text.Trim());
                //}
                //else
                //{
                //    orderMod.YijiekuanMoney = 0;
                //}
                //if (txtYikaipiaoMoney.Text.Trim() != "")
                //{
                //    orderMod.YikaipiaoMoney = Convert.ToDecimal(txtYikaipiaoMoney.Text.Trim());
                //}
                //else
                //{
                //    orderMod.YikaipiaoMoney = 0;
                //}
                ProOrdersBLL.Update(orderMod);
            }
            //修改订单详情

            string[] xinghao = Request.Params.GetValues("proType");
            string[] shuliang = Request.Params.GetValues("proNum");
            string[] danjia = Request.Params.GetValues("ProPrice");
            string[] wuliaobian = Request.Params.GetValues("wuliaobian");

            string xianyouyongpin = "";
            string errmsg = "";
            //原有产品的增加和修改
            for (int i = 0; i < rptYongpin.Items.Count; i++)
            {
                Label lblProType = this.rptYongpin.Items[i].FindControl("lblProType") as Label;
                TextBox txtProNum = this.rptYongpin.Items[i].FindControl("txtProNum") as TextBox;
                Label lblProPrice = this.rptYongpin.Items[i].FindControl("lblProPrice") as Label;
                Label lblWuliaobian = this.rptYongpin.Items[i].FindControl("lblWuliaobian") as Label;
                HiddenField hdborderDetailId = this.rptYongpin.Items[i].FindControl("hdborderDetailId") as HiddenField;
                xianyouyongpin += lblProType.Text.Trim() + ",";

                if (txtProNum != null && txtProNum.Text.Trim() != "" && int.Parse(txtProNum.Text.Trim()) != 0)
                {
                    //修改产品数量
                    int Updcount = ProOrdersDetailBLL.Update(Convert.ToInt32(hdborderDetailId.Value), Convert.ToInt32(txtProNum.Text));
                    if (!(Updcount > 0))
                    {
                        real = false;
                    }
                }
                else
                {
                    //删除产品型号
                    ProOrdersDetailBLL.Delete(Convert.ToInt32(hdborderDetailId.Value));
                }
            }
            //新增产品

            if (xinghao != null && xinghao.Length > 0)
            {
                for (int i = 0; i < xinghao.Length; i++)
                {
                    if (shuliang[i].ToString().Trim() != "" && int.Parse(shuliang[i].ToString().Trim()) != 0)
                    {
                        ProductParamMOD paramMod = ProductParamBLL.GetmodByid(txtcustomNum.Text.Trim(), xinghao[i].Trim());
                        if (paramMod != null)
                        {
                            string xinYongpin = xinghao[i].ToString().Trim();
                            int num = 0;
                            int osid = 0;
                            if (xianyouyongpin.Contains(xinYongpin))   //如果新增产品已经存在于原有的产品中,则数量合并
                            {
                                DataSet ds = ProOrdersDetailBLL.GetList(" and proType='" + xinghao[i].Trim() + "' and orderNum='" + txtorderNum.Text.Trim() + "'");
                                if (ds != null && ds.Tables[0].Rows.Count > 0)
                                {
                                    num = Convert.ToInt32(ds.Tables[0].Rows[0]["proNum"].ToString());
                                    osid = Convert.ToInt32(ds.Tables[0].Rows[0]["orderDetailId"].ToString());
                                    int newNUM = num + Convert.ToInt32(shuliang[i].Trim());
                                    //修改产品数量
                                    int Updcount = ProOrdersDetailBLL.Update(osid, newNUM);
                                    if (!(Updcount > 0))
                                    {
                                        real = false;
                                    }
                                }
                                else
                                {
                                    orderDetail = new ProOrdersDetailMOD();
                                    orderDetail.orderNum = txtorderNum.Text.Trim();
                                    orderDetail.proNum = Convert.ToInt32(shuliang[i].Trim());
                                    orderDetail.ProPrice = Convert.ToDecimal(danjia[i].Trim());
                                    orderDetail.proType = xinghao[i].Trim();
                                    int Addcounts = ProOrdersDetailBLL.Add(orderDetail);
                                    if (!(Addcounts > 0))
                                    {
                                        real = false;
                                    }
                                }
                            }
                            else   //直接添加
                            {
                                orderDetail = new ProOrdersDetailMOD();
                                orderDetail.orderNum = txtorderNum.Text.Trim();
                                orderDetail.proNum = Convert.ToInt32(shuliang[i].Trim());
                                orderDetail.ProPrice = Convert.ToDecimal(danjia[i].Trim());
                                orderDetail.proType = xinghao[i].Trim();
                                //orderDetail.Wuliaobian = wuliaobian[i].Trim();
                                int Addcounts = ProOrdersDetailBLL.Add(orderDetail);
                                if (!(Addcounts > 0))
                                {
                                    real = false;
                                }
                            }
                        }
                        else
                        {
                            errmsg += xinghao[i] + ",";
                        }
                    }

                }
            }
            if (real)
            {
                if (errmsg == "")
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "DetailsPageControl.ReflushList('orderManage/OrderManage.aspx');", true);

                    //   ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "DetailsPageControl.ReflushList('orderManage/OrderManage.aspx');print();DetailsPageControl.CloseBox();", true);
                    Response.Redirect("Contract.aspx?customerNo=" + txtcustomNum.Text.Trim() + "&orderNum=" + txtorderNum.Text.Trim());
                }
                else
                {
                    //  ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert(" + errmsg + "'没有维护单价提交失败,其余提交成功');", true);
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert('" + errmsg + "没有维护产品参数提交失败,其余提交成功');DetailsPageControl.ReflushList('orderManage/OrderManage.aspx');", true);
                    Response.Redirect("Contract.aspx?customerNo=" + txtcustomNum.Text.Trim() + "&orderNum=" + txtorderNum.Text.Trim());
                }
                //  ScriptManager.RegisterStartupScript(Page, typeof(Page), "BGYPSQLB", "DetailsPageControl.CloseBox();alert('提交成功!');DetailsPageControl.ReflushList('orderManage/OrderManage.aspx');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "BGYPSQLB", "alert('提交失败!')", true);
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "BGYPSQLB", "alert('提交失败,您输入的信息有误!')", true);
        }
    }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != "")
            {
                string orderNum = Request.QueryString["id"].ToString();
                int id;
                if (Int32.TryParse(Request.QueryString["id"], out id))
                {
                    var db=new Web.Model.OrderPrintEntities();
                    orderNum = db.proOrders.Where(r => r.orderId == id).FirstOrDefault().orderNum;
                }

                //加载订单基本信息
                orderMod = ProOrdersBLL.GetModel(orderNum);
                if (orderMod != null)
                {
                    txtcustomManager.Text = orderMod.customManager;
                    txtcustomNum.Text = orderMod.customNum;
                    txtcustomOrderNum.Text = orderMod.customOrderNum;
                    //  txtcustomWLBH.Text = orderMod.customWLBH;
                    txtheTongNum.Text = orderMod.heTongNum;
                    txtorderNum.Text = orderMod.orderNum;
                    txtremark.Text = orderMod.remark;
                    //txtshuChuXianchang.Text = orderMod.ShuChuXianchang;
                    //txtshuRuXianchang.Text = orderMod.ShuRuXianchang;
                    //txtYijiekuanMoney.Text = orderMod.YijiekuanMoney.ToString();
                    //txtYikaipiaoMoney.Text = orderMod.YikaipiaoMoney.ToString();

                    var db = new Web.Model.OrderPrintEntities();
                    var intorderDetailId = id;
                    var gt_order = db.proOrders.FirstOrDefault(r => r.orderId == orderMod.orderId);
                    if (!string.IsNullOrEmpty(gt_order.发货状态))
                    {
                        rbl发货状态.SelectedValue = gt_order.发货状态;
                    }

                }
                //加载订单产品
                string strWhere = " and orderNum='" + orderNum + "'";
                DataSet ds = ProOrdersDetailBLL.GetList(strWhere);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    rptYongpin.DataSource = ds;
                    rptYongpin.DataBind();
                    txtTRLastIndex.Value = ds.Tables[0].Rows.Count.ToString();
                }
                else
                {
                    txtTRLastIndex.Value = "0";
                }
                //查看客户是否客户提供合同范本,如客户提供,打印合同按钮隐藏
                customer = CustomerManageBLL.GetcustomerByid(orderMod.customNum);
                if (customer != null)
                {
                    if (customer.IsFanben == 0)
                    {
                        tishi.InnerText = "本客户自己提供合同模板,请使用签订客户合同";
                        IBtn_Print.Visible = false;
                    }
                    else
                    {
                        IBtn_Print.Visible = true;
                    }
                }
                else
                {
                    IBtn_Print.Visible = true;
                }
                //订单号、客户编号不允许修改
                txtorderNum.Enabled = false;
                txtcustomNum.Enabled = false;
            }
        }
    }
    /// <summary>
    /// 添加
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Save_Click(object sender, ImageClickEventArgs e)
    {
        int num = 0;

        if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null)
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            customer = CustomerManageBLL.GetcustomerByid(id);
            customer.BackMethod = txtbackMethod.Text.Trim();
            customer.CompanyAddress = txtcompanyAddress.Text.Trim();
            customer.CompanyName = txtcompanyName.Text.Trim();
            customer.Contacts = txtcontacts.Text.Trim();
            customer.Description = txtdescription.Text.Trim();

            customer.Discount = txtdiscount.Text.Trim();

            customer.InvoiceMethod = txtInvoiceMethod.Text.Trim();
            customer.IsFanben = rdoIsFanbenYes.Checked ? 0 : 1;
            customer.IsShowPrice = rdoIsShowPriceYes.Checked ? 0 : 1;
            customer.ModifyPriceRecord = txtmodifyPriceRecord.Text.Trim();
            customer.OtherDangAn = txtotherDangAn.Text.Trim();
            customer.Phone = txtphone.Text.Trim();
            customer.Position = txtposition.Text.Trim();
            customer.Tax = txttax.Text.Trim();
            customer.TelPhone = txttelPhone.Text.Trim();
            customer.ShuiHao = txtShuiHao.Text.Trim();
            customer.ZhangHao = txtZhangHao.Text.Trim();
            if (rdoIsAdd.Checked == true)
            {
                customer.IsAddInfo = 1;
            }
            else
            {
                customer.IsAddInfo = 0;
            }
            num = CustomerManageBLL.Updatecustomer(customer);
        }
        else
        {
            customer = new CustomerManageMod();
            customer.CustomerNo = txtcustomerNo.Text.Trim();
            customer.BackMethod = txtbackMethod.Text.Trim();
            customer.CompanyAddress = txtcompanyAddress.Text.Trim();
            customer.CompanyName = txtcompanyName.Text.Trim();
            customer.Contacts = txtcontacts.Text.Trim();
            customer.Description = txtdescription.Text.Trim();

            customer.Discount = txtdiscount.Text.Trim();

            customer.InvoiceMethod = txtInvoiceMethod.Text.Trim();
            customer.IsFanben = rdoIsFanbenYes.Checked ? 0 : 1;
            customer.IsShowPrice = rdoIsShowPriceYes.Checked ? 0 : 1;
            customer.ModifyPriceRecord = txtmodifyPriceRecord.Text.Trim();
            customer.OtherDangAn = txtotherDangAn.Text.Trim();
            customer.Phone = txtphone.Text.Trim();
            customer.Position = txtposition.Text.Trim();
            customer.Tax = txttax.Text.Trim();
            customer.TelPhone = txttelPhone.Text.Trim();
            customer.ShuiHao = txtShuiHao.Text.Trim();
            customer.ZhangHao = txtZhangHao.Text.Trim();
            if (rdoIsAdd.Checked == true)
            {
                customer.IsAddInfo = 1;
            }
            else
            {
                customer.IsAddInfo = 0;
            }
            using (var db = new OrderPrintEntities())
            {
                if (db.customer.Count(r => r.companyName == customer.CompanyName) > 0)
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert('提交失败,一个公司名只能对应一个客户编号!');", true);
                    return;

                }
            }

            num = CustomerManageBLL.Insertcustomer(customer);
        }
        if (num > 0)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "DetailsPageControl.CloseBox();alert('提交成功');DetailsPageControl.ReflushList('CustomerManage/CustomerManage.aspx');", true);
        }
        else
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert('提交失败');", true);
        }
    }