コード例 #1
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            //下单
            try
            {
                if (txtShipDate.Text.Length == 0)
                {
                    throw new Exception("请输入发货日期");
                }
                OrderBook orderBook = new OrderBook();
                if (ddlOrderType.SelectedValue == "WDO")
                {
                    if (txtArrivedDate.Text.Length == 0)
                    {
                        throw new Exception("请输入要求到货时间");
                    }
                    orderBook.cndArrivedDate  = DateTime.Parse(txtArrivedDate.Text);
                    orderBook.cnvcCustomName  = txtCustomName.Text;
                    orderBook.cnvcLinkPhone   = txtLinkPhone.Text;
                    orderBook.cnvcShipAddress = txtShipAddress.Text;
                }
                if (ddlOrderType.SelectedValue == "SELFPRODUCE")
                {
                    if (!ddlSalesRoom.SelectedValue.Equals(ddlProduceDept.SelectedValue))
                    {
                        throw new Exception("门市自生产下单门市必需和生产单位一致!");
                    }
                }

                orderBook.cndShipDate       = DateTime.Parse(txtShipDate.Text);
                orderBook.cnvcOrderDeptID   = ddlSalesRoom.SelectedValue;
                orderBook.cnvcOrderState    = "0";
                orderBook.cnvcOrderType     = ddlOrderType.SelectedValue;
                orderBook.cnvcProduceDeptID = ddlProduceDept.SelectedValue;
                orderBook.cnvcOrderComments = txtOrderComments.Text;
                DataTable dtDetail = (DataTable)Session["ProductList"];

                Hashtable htDetail = new Hashtable();
                foreach (DataRow dr in dtDetail.Rows)
                {
                    string strProductCode = dr["cnvcProductCode"].ToString();
                    string strProductName = dr["cnvcProductName"].ToString();
                    if (htDetail.ContainsKey(strProductCode))
                    {
                        throw new Exception(strProductCode + "-" + strProductName + "重复,请首先通过产品查询或者订单细节进行修改");
                    }
                    else
                    {
                        htDetail.Add(strProductCode, strProductName);
                    }
                }

                OperLog operLog = new OperLog();
                operLog.cnvcOperID   = oper.strLoginID;
                operLog.cnvcDeptID   = oper.strDeptID;
                operLog.cnvcOperType = "下单";

                OrderFacade order = new OrderFacade();
                order.AddOrder(orderBook, dtDetail, operLog);
                Session["ProductList"] = null;
                btnCancel_Click(null, null);
                this.DataGrid1.DataSource = null;
                this.DataGrid1.DataBind();
                Popup("下单成功");
                BindDisp();
            }
            catch (Exception ex)
            {
                Popup(ex.Message);
            }
        }
コード例 #2
0
        protected void btnOK_Click(object sender, System.EventArgs e)
        {
            //下单
            try
            {
                if (txtShipDate.Text.Length == 0)
                {
                    throw new Exception("请输入发货日期");
                }
                OrderBook orderBook = new OrderBook();
                if (ddlOrderType.SelectedValue == "WDO")
                {
                    if (txtArrivedDate.Text.Length == 0)
                    {
                        throw new Exception("请输入要求到货时间");
                    }
                    orderBook.cndArrivedDate  = DateTime.Parse(txtArrivedDate.Text);
                    orderBook.cnvcCustomName  = txtCustomName.Text;
                    orderBook.cnvcLinkPhone   = txtLinkPhone.Text;
                    orderBook.cnvcShipAddress = txtShipAddress.Text;
                }
                if (ddlOrderType.SelectedValue == "SELFPRODUCE")
                {
                    if (!ddlSalesRoom.SelectedValue.Equals(ddlProduceDept.SelectedValue))
                    {
                        throw new Exception("门市自生产下单门市必需和生产单位一致!");
                    }
                }
                orderBook.cndShipDate       = DateTime.Parse(txtShipDate.Text);
                orderBook.cnvcOrderDeptID   = ddlSalesRoom.SelectedValue;
                orderBook.cnvcOrderState    = "0";
                orderBook.cnvcOrderType     = ddlOrderType.SelectedValue;
                orderBook.cnvcProduceDeptID = ddlProduceDept.SelectedValue;
                orderBook.cnvcOrderComments = txtOrderComments.Text;
                DataTable dtDetail = (DataTable)Session["ProductList"];

                Hashtable htDetail = new Hashtable();
                foreach (DataRow dr in dtDetail.Rows)
                {
                    string    strProductCode = dr["cnvcProductCode"].ToString();
                    string    strProductName = dr["cnvcProductName"].ToString();
                    string    strsql         = "select cnvcProductTypeCode as cnvcProductType from vwProduct where cnvcProductCode='" + strProductCode + "'";
                    DataTable dtProductType  = Helper.Query(strsql);
                    if (dtProductType == null || dtProductType.Rows.Count == 0)
                    {
                        throw new Exception("获取" + strProductName + "的产品类型错误");
                    }
                    string strProductType = dtProductType.Rows[0]["cnvcProductType"].ToString();
                    if (strProductType == "Raw" || strProductType == "Pack")
                    {
                        if (ddlOrderType.SelectedValue != "MATERIAL")
                        {
                            throw new Exception(strProductCode + "-" + strProductName + "为原材料,订单类型请选择原材料订单");
                        }
                    }
                    if (strProductType == "SEMIPRODUCT" || strProductType == "FINALPRODUCT")
                    {
                        if (ddlOrderType.SelectedValue == "MATERIAL")
                        {
                            throw new Exception(strProductCode + "-" + strProductName + "不是原材料,订单类型不能选择原材料订单");
                        }
                    }
                    if (htDetail.ContainsKey(strProductCode))
                    {
                        throw new Exception(strProductCode + "-" + strProductName + "重复,请首先通过产品查询或者订单细节进行修改");
                    }
                    else
                    {
                        htDetail.Add(strProductCode, strProductName);
                    }
                }

                OperLog operLog = new OperLog();
                operLog.cnvcOperID   = oper.strLoginID;
                operLog.cnvcDeptID   = oper.strDeptID;
                operLog.cnvcOperType = "下单";

                OrderFacade order = new OrderFacade();
                order.AddOrder(orderBook, dtDetail, operLog);
                Session["ProductList"] = null;
                btnCancel_Click(null, null);
                this.DataGrid1.DataSource = null;
                this.DataGrid1.DataBind();
                Popup("下单成功");
                BindDisp();
            }
            catch (Exception ex)
            {
                AMSApp.zhenghua.Common.LogAdapter.WriteInterfaceException(ex);
                Popup(ex.Message);
            }
        }
コード例 #3
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            //下单
            try
            {
                if (txtShipDate.Text.Length == 0)
                {
                    throw new Exception("请输入发货日期");
                }
                if (this.JudgeIsNull(this.txtOrderDate.Text))
                {
                    this.Popup("请输入订单日期");
                    return;
                }
                OrderBook orderBook = new OrderBook();
                orderBook.cnvcOperID = oper.strLoginID;
                if (this.txtOrderSerialNo.Text != "")
                {
                    orderBook.cnnOrderSerialNo = Convert.ToDecimal(this.txtOrderSerialNo.Text);
                }
                if (ddlOrderType.SelectedValue == "WDO" || ddlOrderType.SelectedValue == "WDOSELF")
                {
                    if (txtArrivedDate.Text.Length == 0)
                    {
                        throw new Exception("请输入要求到货时间");
                    }
                    orderBook.cndArrivedDate  = DateTime.Parse(txtArrivedDate.Text);
                    orderBook.cnvcCustomName  = txtCustomName.Text;
                    orderBook.cnvcLinkPhone   = txtLinkPhone.Text;
                    orderBook.cnvcShipAddress = txtShipAddress.Text;
                }
                if (ddlOrderType.SelectedValue == "SELFPRODUCE" || ddlOrderType.SelectedValue == "WDOSELF")
                {
                    if (!ddlSalesRoom.SelectedValue.Equals(ddlProduceDept.SelectedValue))
                    {
                        throw new Exception(ddlOrderType.SelectedItem.Text + "门市必需和生产单位一致!");
                    }
                }
                orderBook.cndOrderDate      = Convert.ToDateTime(txtOrderDate.Text);
                orderBook.cndShipDate       = DateTime.Parse(txtShipDate.Text);
                orderBook.cnvcOrderDeptID   = ddlSalesRoom.SelectedValue;
                orderBook.cnvcOrderState    = "0";
                orderBook.cnvcOrderType     = ddlOrderType.SelectedValue;
                orderBook.cnvcProduceDeptID = ddlProduceDept.SelectedValue;
                orderBook.cnvcOrderComments = txtOrderComments.Text;
                DataTable dtDetail = (DataTable)Session["ProductList"];
                if (dtDetail == null)
                {
                    throw new Exception("请查询产品,添加产品清单!");
                }
                Hashtable htDetail = new Hashtable();
                foreach (DataRow dr in dtDetail.Rows)
                {
                    string strProductCode = dr["cnvcinvcode"].ToString();
                    string strProductName = dr["cnvcinvname"].ToString();
                    if (htDetail.ContainsKey(strProductCode))
                    {
                        throw new Exception(strProductCode + "-" + strProductName + "重复,请首先通过产品查询进行修改");
                    }
                    else
                    {
                        htDetail.Add(strProductCode, strProductName);
                    }
                }

                OperLog operLog = new OperLog();
                operLog.cnvcOperID   = oper.strLoginID;
                operLog.cnvcDeptID   = oper.strDeptID;
                operLog.cnvcOperType = "下单";

                OrderFacade order = new OrderFacade();
                order.AddOrder(orderBook, dtDetail, operLog);
                Session["ProductList"] = null;
                btnCancel_Click(null, null);
                this.DataGrid1.DataSource = null;
                this.DataGrid1.DataBind();
                Popup("下单成功", "wfmOrderQuery.aspx");
                //this.Button2_Click(null,null);
                //this.Response.Redirect("wfmOrderQuery.aspx",false);
            }
            catch (Exception ex)
            {
                Popup(ex.Message);
            }
        }