예제 #1
0
파일: FaHuo.aspx.cs 프로젝트: 892182825/SP
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (DropDownList2.SelectedItem == null || DropDownList1.SelectedItem == null)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001301", "请选择创库和库位!") + "')</script>");
        }
        else
        {
            string storeOrderID = Request.QueryString["StoreOrderID"].ToString();

            string outStorageOrderID = "CK" + OrderGoodsBLL.GetNewOrderID();
            ViewState["ckd"] = outStorageOrderID;
            //已发货
            if (DAL.DBHelper.ExecuteScalar("select IsSend from InventoryDoc where docid='" + Request.QueryString["StoreOrderID"] + "'").ToString() == "1")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('已经发货了!')</script>");
            }
            //已出库
            //else if (DAL.DBHelper.ExecuteScalar("select IsGeneOutBill from StoreOrder where StoreOrderID='" + Request.QueryString["StoreOrderID"] + "'").ToString().ToLower() == "y")
            //{
            //    outStorageOrderID = BLL.CommonClass.CommonDataBLL.getOutStorageOrderId(storeOrderID);
            //    ViewState["ckd"] = outStorageOrderID;
            //    SetFH();
            //}
            else //未出库
            {
                //StoreOrderModel som = BillOutOrderBLL.GetStoreOrderModel_II(storeOrderID);
                //List<OrderDetailModel> l_odm = BillOutOrderBLL.GetOrderDetailModelList(storeOrderID);

                //InventoryDocModel idm = new InventoryDocModel();

                //idm.Currency = Convert.ToInt32(Request.QueryString["Country"]);
                ////idm.DocAuditTime = som.AuditingDate;
                //idm.DocTypeID = Convert.ToInt32(DBHelper.ExecuteScalar("select DocTypeId from dbo.DocTypeTable where DocTypeCode='FH'"));  //
                //idm.DocMaker = TextBox4.Text;
                //idm.Client = som.StoreId;
                //idm.DepotSeatID = Convert.ToInt32(DropDownList2.SelectedItem.Value);
                //idm.WareHouseID = Convert.ToInt32(DropDownList1.SelectedItem.Value);
                ////idm.DepotSeatID = Convert.ToInt32(Session["depotSeatID"]);
                ////idm.WareHouseID = Convert.ToInt32(Session["wareHouseID"]);
                //idm.TotalMoney = Convert.ToDouble(som.TotalMoney);
                //idm.TotalPV = Convert.ToDouble(som.TotalPv);
                //idm.ExpectNum = som.ExpectNum;
                //idm.Cause = "FH";
                //idm.Note = TextBox6.Text.Trim();
                //idm.StateFlag = 1;
                //idm.CloseFlag = 0;
                //idm.OperationPerson = "";//业务员
                //idm.OriginalDocID = som.StoreorderId;
                //idm.Address = som.InceptAddress;

                //List<InventoryDocDetailsModel> l_ddm = new List<InventoryDocDetailsModel>();

                //for (int i = 0; i < l_odm.Count; i++)
                //{
                //    InventoryDocDetailsModel ddm = new InventoryDocDetailsModel();

                //    ddm.ProductID = l_odm[i].ProductId;
                //    ddm.ProductQuantity = Convert.ToDouble(l_odm[i].Quantity);
                //    ddm.UnitPrice = Convert.ToDouble(l_odm[i].Price);
                //    ddm.PV = Convert.ToDouble(l_odm[i].Pv);
                //    ddm.ProductTotal = Convert.ToDouble(l_odm[i].Quantity) * Convert.ToDouble(l_odm[i].Price);
                //    ddm.MeasureUnit = "";

                //    l_ddm.Add(ddm);
                //}

                //string rt = BillOutOrderBLL.OutOrder(storeOrderID, outStorageOrderID, idm, l_ddm);

                //if (rt == "1" || rt=="-88")
                //{
                SetFH();
                //}
                //else if (rt == "0")
                //    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001304", "库存不够!") + "')</script>");
                //else if (rt == "-6")
                //    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001309", "仓库库位上没有货!") + "')</script>");
                //else
                //    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001714", "发货失败!!") + rt + "')</script>");
            }
        }
    }
예제 #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (DropDownList2.SelectedItem == null || DropDownList1.SelectedItem == null)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001301", "请选择创库和库位!") + "')</script>");
            this.Button1.Text = GetTran("001290", "确定出库");
        }
        else
        {
            string err = "";
            string PrepareProduct_PrepareTime = DateTime.Now.ToString();
            string PrepareProduct_OperateNum  = Session["Company"].ToString();
            string PrepareProduct_OperateIP   = Request.UserHostAddress;
            string outStorageOrderID          = "";
            string GroupCK = "";

            string[] arrstoreOrderID = Request.QueryString["StoreOrderID"].ToString().Replace("'", "").Replace("-", "").Replace("/*", "").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            for (int k = 0; k < arrstoreOrderID.Length; k++)
            {
                outStorageOrderID = "CK" + OrderGoodsBLL.GetNewOrderID();
                GroupCK           = GroupCK + outStorageOrderID + ",";

                StoreOrderModel         som   = BillOutOrderBLL.GetStoreOrderModel_II(arrstoreOrderID[k]);
                List <OrderDetailModel> l_odm = BillOutOrderBLL.GetOrderDetailModelList(arrstoreOrderID[k]);

                string            sql     = "select isnull(m.number,'') number,s.storeid,s.sendway from storeorder s left join ordergoods o on s.storeorderid=o.fahuoorder left join memberorder m on o.memberorderid=m.orderid where s.storeorderid='" + arrstoreOrderID[k] + "'";
                DataTable         dt      = DBHelper.ExecuteDataTable(sql);
                string            sendway = dt.Rows[0]["sendway"].ToString();
                string            number  = dt.Rows[0]["number"].ToString();
                string            storeid = dt.Rows[0]["storeid"].ToString();
                InventoryDocModel idm     = new InventoryDocModel();

                //idm.DocAuditTime = som.AuditingDate;
                idm.DocTypeID = Convert.ToInt32(DAL.DBHelper.ExecuteScalar("select DocTypeId from dbo.DocTypeTable where DocTypeCode='CK'"));   //出库单
                idm.DocMaker  = TextBox4.Text;
                if (sendway == "1")
                {
                    idm.Client = number;
                }
                else
                {
                    idm.Client = storeid;
                }
                idm.DepotSeatID     = Convert.ToInt32(DropDownList2.SelectedItem.Value);
                idm.WareHouseID     = Convert.ToInt32(DropDownList1.SelectedItem.Value);
                idm.ExpectNum       = som.ExpectNum;
                idm.Note            = TextBox6.Text.Trim();
                idm.StateFlag       = 1;
                idm.CloseFlag       = 0;
                idm.OperationPerson = "";//业务员
                idm.OriginalDocID   = arrstoreOrderID[k];
                idm.Address         = som.InceptAddress;
                idm.Storeorderid    = arrstoreOrderID[k];

                List <InventoryDocDetailsModel> l_ddm = new List <InventoryDocDetailsModel>();
                double totalmoney = 0;
                double totalpv    = 0;
                foreach (RepeaterItem item in Repeater1.Items)
                {
                    HiddenField HF        = (HiddenField)item.FindControl("HF");
                    Label       lblPrice  = (Label)item.FindControl("lblPrice");
                    Label       lblPV     = (Label)item.FindControl("lblPV");
                    Label       txtCount1 = (Label)item.FindControl("txtCount1");
                    TextBox     txtCount  = (TextBox)item.FindControl("txtCount");
                    int         count     = 0;

                    int.TryParse(txtCount.Text, out count);

                    if (count > 0)
                    {
                        if (Convert.ToInt32(txtCount.Text) > Convert.ToInt32(txtCount1.Text))
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "msg", "alert('" + GetTran("007716", "出库数量不能大于剩余数量!") + "');", true);
                            this.Button1.Text = GetTran("001290", "确定出库");
                            return;
                        }

                        if (Convert.ToInt32(DAL.DBHelper.ExecuteScalar("select COUNT(0) from OrderDetail where StoreOrderID='" + arrstoreOrderID[k] + "' and ProductID=" + Convert.ToInt32(HF.Value) + " and (Quantity-OutBillQuantity)<" + count)) > 0)
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "msg", "alert('" + GetTran("007716", "出库数量不能大于剩余数量!") + "');", true);
                            this.Button1.Text = GetTran("001290", "确定出库");
                            loadData();
                            return;
                        }

                        InventoryDocDetailsModel ddm = new InventoryDocDetailsModel();

                        ddm.ProductID       = Convert.ToInt32(HF.Value);
                        ddm.ProductQuantity = Convert.ToInt32(txtCount.Text);
                        ddm.UnitPrice       = Convert.ToDouble(lblPrice.Text);
                        ddm.PV           = Convert.ToDouble(lblPV.Text);
                        ddm.ProductTotal = Convert.ToDouble(txtCount.Text) * Convert.ToDouble(lblPrice.Text);
                        ddm.MeasureUnit  = "";
                        totalmoney      += Convert.ToDouble(txtCount.Text) * Convert.ToDouble(lblPrice.Text);
                        totalpv         += Convert.ToDouble(txtCount.Text) * Convert.ToDouble(lblPV.Text);
                        l_ddm.Add(ddm);
                    }
                }
                idm.TotalMoney = totalmoney;
                idm.TotalPV    = totalpv;
                if (l_ddm.Count <= 0)
                {
                    string getcount = " select sum(quantity-outbillquantity) from orderdetail where storeorderid='" + arrstoreOrderID[k] + "'";
                    object ckk      = DBHelper.ExecuteScalar(getcount, CommandType.Text);
                    if (ckk.ToString() == null || ckk.ToString() == "")
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "msg", "alert('没有商品暂时没法出库!')", true);
                    }
                    else
                    {
                        if (int.Parse(ckk.ToString()) <= 0)
                        {
                            DBHelper.ExecuteNonQuery("update storeorder set IsGeneOutBill='A' where storeorderid='" + arrstoreOrderID[k] + "'");
                        }
                    }
                    ScriptManager.RegisterStartupScript(this, GetType(), "msg", "alert('" + GetTran("007721", "请输入出库数量!") + "')", true);
                    this.Button1.Text = GetTran("001290", "确定出库");
                    return;
                }

                string rt = BillOutOrderBLL.OutOrder(arrstoreOrderID[k], outStorageOrderID, idm, l_ddm);

                if (rt == "1")
                {
                    int hs = 0;

                    string getcount = " select sum(quantity-outbillquantity) from orderdetail where storeorderid='" + arrstoreOrderID[k] + "'";
                    if (int.Parse(DBHelper.ExecuteScalar(getcount, CommandType.Text).ToString()) <= 0)
                    {
                        hs = DBHelper.ExecuteNonQuery("update storeorder set IsGeneOutBill='A' where storeorderid='" + arrstoreOrderID[k] + "'");
                    }
                    else
                    {
                        hs = DBHelper.ExecuteNonQuery("update storeorder set IsGeneOutBill='Y' where storeorderid='" + arrstoreOrderID[k] + "'");
                    }
                    if (hs == 1)
                    {
                        //PrepareProduct_DocIDs = PrepareProduct_DocIDs + arrstoreOrderID[k] + ",";
                        //PrepareProduct_TotalMoney = PrepareProduct_TotalMoney + Convert.ToDouble(idm.TotalMoney);
                        //PrepareProduct_TotalPv = PrepareProduct_TotalPv + Convert.ToDouble(idm.TotalPV);
                    }
                    else
                    {
                        err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007722", " 的产品出库失败!");
                    }
                }
                else if (rt == "0")
                {
                    err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007723", " 的产品库存不够!");
                }
                else if (rt == "-6")
                {
                    err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007724", " 的产品仓库库位上没有货!");
                }
                else if (rt == "-5")
                {
                    err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007725", " 的产品更新出库数量错误!");
                }
                else if (rt == "-88")
                {
                    err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007726", " 的产品已经出库!");
                }
                else
                {
                    err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007727", " 的产品出库失败!");
                }
            }

            if (err == "")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>if(window.confirm('" + GetTran("001297", "生成的出库单号为:") + outStorageOrderID + GetTran("001298", ",您要打印此出库单吗?") + "')) window.open('docPrint.aspx?docID=" + outStorageOrderID + "');window.location.href='BillOutOrder.aspx';</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + err + "');window.location.href='BillOutOrder.aspx'</script>");
            }

            this.Button1.Text = GetTran("001290", "确定出库");
        }
    }