Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (RequestActionString)
            {
            case "batchdelete":
                IList <object> idList = RequestData.GetList <object>("IdList");
                if (idList != null && idList.Count > 0)
                {
                    foreach (object obj in idList)
                    {
                        InWarehouse[] iwEnts = InWarehouse.FindAllByProperties("PublicInterface", obj.ToString());
                        if (iwEnts.Length > 0)
                        {
                            OtherInWarehouseDetail.DeleteAll("InWarehouseId='" + iwEnts[0].Id + "'");
                            InWarehouse.DeleteAll("PublicInterface='" + obj.ToString() + "'");
                        }
                        DeliveryOrder[] doEnts = DeliveryOrder.FindAllByProperties("PId", obj.ToString());
                        if (doEnts.Length > 0)
                        {
                            DelieryOrderPart.DeleteAll("DId='" + doEnts[0].Id + "'");
                            DeliveryOrder.DeleteAll("PId='" + obj.ToString() + "'");
                        }
                        DataHelper.ExecSql("delete SHHG_AimExamine..WarehouseExchange where Id='" + obj.ToString() + "'");
                        DataHelper.ExecSql("delete SHHG_AimExamine..WarehouseExchangeDetail where WarehouseExchangeId='" + obj.ToString() + "'");
                        PageState.Add("Message", "删除成功!");
                    }
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加出库商品信息
        /// </summary>
        private void InsertPart(IList <string> strList, string Did)
        {
            Dictionary <string, object> dic     = null;
            DelieryOrderPart            entPart = null;

            for (int i = 0; i < strList.Count; i++)
            {
                dic = FromJson(strList[i]) as Dictionary <string, object>;

                if (dic != null)
                {
                    //一个一个的添加
                    entPart = new DelieryOrderPart
                    {
                        DId        = Did,
                        PId        = dic["PId"] + "",
                        ProductId  = dic["ProductId"] + "",
                        PName      = dic["Name"] + "",
                        PCode      = dic["Code"] + "",
                        Isbn       = dic.ContainsKey("Isbn") ? dic["Isbn"] + "" : "",
                        Unit       = dic.ContainsKey("Unit") ? dic["Unit"] + "" : null,
                        Count      = dic.ContainsKey("OutCount") ? (int?)Convert.ToInt32(dic["OutCount"]) : null,
                        Remark     = dic.ContainsKey("Remark") ? dic["Remark"] + "" : "",
                        State      = "未出库",
                        Guids      = dic.ContainsKey("Guids") ? dic["Guids"] + "" : "",
                        CreateId   = UserInfo.UserID,
                        CreateName = UserInfo.Name,
                        CreateTime = DateTime.Now
                    };
                    entPart.DoCreate();
                }
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (RequestActionString)
            {
            case "Update":
                id                = RequestData.Get <string>("id");
                InvoiceNo         = RequestData.Get <string>("InvoiceNo");
                NewCostPrice      = RequestData.Get <decimal>("NewCostPrice");
                dopEnt            = DelieryOrderPart.Find(id);
                dopEnt.CostPrice  = NewCostPrice;
                dopEnt.CostAmount = Math.Round(NewCostPrice * Convert.ToDecimal(dopEnt.Count) / Convert.ToDecimal(1.17), 2);
                dopEnt.InvoiceNo  = InvoiceNo;
                dopEnt.DoUpdate();
                Product pEnt = Product.Find(dopEnt.ProductId);
                if (pEnt.CostPrice != NewCostPrice)
                {
                    pEnt.CostPrice = NewCostPrice;
                    pEnt.DoUpdate();
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DeliveryOrder order     = DeliveryOrder.TryFind(Request.QueryString["Id"]);
            int           pageindex = Request.QueryString["pageindex"] + "" == "" ? 1 : Convert.ToInt32(Request.QueryString["pageindex"]);

            if (order == null)
            {
                return;
            }
            lblbianhao.InnerText         = order.Number;
            lblCustomerOrderNo.InnerText = "";
            lbldizhi.InnerText           = order.Address;
            lblfphm.InnerText            = "";
            lblghdw.InnerText            = order.CName;
            lbljhfs.InnerText            = order.DeliveryMode;
            SaleOrder saleOrder = SaleOrder.TryFind(order.PId + "");

            lblkdr.InnerText     = saleOrder != null ? saleOrder.CreateName : "";
            lbllxdh.InnerText    = order.Tel;
            lblriqi.InnerText    = DateTime.Now.ToString("yyyy-MM-dd");
            lblxsjl.InnerText    = "";
            lblywy.InnerText     = order.Salesman;
            lblzhaiyao.InnerText = order.Remark;
            //循环子商品
            DelieryOrderPart[] deOrderParts = DelieryOrderPart.FindAllByProperty("DId", order.Id);
            string             db           = ConfigurationManager.AppSettings["ExamineDB"];
            int pagecount = DataHelper.QueryValue <int>("select top 1 Count from " + db + "..PrintCount");

            for (int i = 0; i < deOrderParts.Length; i++)
            {
                if (i < (pageindex - 1) * pagecount)
                {
                    continue;
                }
                if (i >= pageindex * pagecount)
                {
                    break;
                }

                lit.Text += "<tr align='center'><td>" + deOrderParts[i].PName + "</td>";
                lit.Text += "<td>" + deOrderParts[i].PCode + "</td>";
                lit.Text += "<td>" + deOrderParts[i].Unit + "</td>";
                lit.Text += "<td>" + deOrderParts[i].Count + "</td>";
                lit.Text += "<td></td>";
                lit.Text += "<td></td>";
                lit.Text += "<td>" + deOrderParts[i].Remark + "</td>";
                lit.Text += "<td>" + DateTime.Now.ToString("yyyy-MM-dd") + "</td></tr>";

                //count += deOrderParts[i].Count;
                //amount += deOrderParts[i].Count
            }
        }
Exemplo n.º 5
0
        private string InsertPart(IList <string> strList, string Did)
        {
            string        deliveryState         = "已出库";
            List <string> listState             = new List <string>();
            Dictionary <string, object> dic     = null;
            DelieryOrderPart            entPart = null;

            for (int i = 0; i < strList.Count; i++)
            {
                dic = FromJson(strList[i]) as Dictionary <string, object>;

                if (dic != null)
                {
                    //一个一个的添加
                    entPart = new DelieryOrderPart
                    {
                        DId        = Did,
                        PId        = dic.ContainsKey("PId") ? dic["PId"] + "" : "",
                        ProductId  = dic["ProductId"] + "",
                        PName      = dic["Name"] + "",
                        PCode      = dic["Code"] + "",
                        Isbn       = dic.ContainsKey("Isbn") ? dic["Isbn"] + "" : "",
                        Unit       = dic.ContainsKey("Unit") ? dic["Unit"] + "" : "",
                        Count      = dic.ContainsKey("Count") ? Convert.ToInt32(dic["Count"]) : 0,
                        OutCount   = Convert.ToInt32(dic["OutCount"]) + (dic.ContainsKey("SmCount") && dic["SmCount"] + "" != "" ? Convert.ToInt32(dic["SmCount"]) : 0),
                        Remark     = dic.ContainsKey("Remark") ? dic["Remark"] + "" : "",
                        State      = "部分出库",
                        Guids      = dic.ContainsKey("Guids") ? dic["Guids"] + "" : "",
                        CreateId   = UserInfo.UserID,
                        CreateName = UserInfo.Name,
                        CreateTime = DateTime.Now
                    };
                    if (entPart.OutCount == entPart.Count)
                    {
                        entPart.State = "已出库";
                    }
                    else if (entPart.OutCount == null || entPart.OutCount == 0)
                    {
                        entPart.State = "未出库";
                    }
                    listState.Add(entPart.State);
                    entPart.DoCreate();
                }
            }
            if (listState.IndexOf("未出库") > -1 || listState.IndexOf("部分出库") > -1)
            {
                deliveryState = "部分出库";
            }
            return(deliveryState);
        }
Exemplo n.º 6
0
 private void ProcessDeliveryOrderDetail(IList <string> entStrList, DeliveryOrder doEnt)
 {
     if (entStrList != null && entStrList.Count > 0)
     {
         for (int j = 0; j < entStrList.Count; j++)
         {
             JObject          json   = JsonHelper.GetObject <JObject>(entStrList[j]);
             DelieryOrderPart dopEnt = new DelieryOrderPart();
             dopEnt.DId        = doEnt.Id;
             dopEnt.Isbn       = json.Value <string>("ProductIsbn");
             dopEnt.PCode      = json.Value <string>("ProductCode");
             dopEnt.PName      = json.Value <string>("ProductName");
             dopEnt.ProductId  = json.Value <string>("ProductId");
             dopEnt.Count      = json.Value <int>("ExchangeQuantity");
             dopEnt.State      = "未出库";
             dopEnt.CreateId   = UserInfo.UserID;
             dopEnt.CreateName = UserInfo.Name;
             dopEnt.CreateTime = System.DateTime.Now;
             dopEnt.DoCreate();
         }
     }
 }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string db = ConfigurationManager.AppSettings["ExamineDB"];

            op      = RequestData.Get <string>("op");
            id      = RequestData.Get <string>("id");
            paid    = RequestData.Get <string>("paid");
            PAState = RequestData.Get <string>("PAState");
            type    = RequestData.Get <string>("type");

            SaleOrder      ent     = null;
            IList <string> strList = RequestData.GetList <string>("data");

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                ent = this.GetMergedData <SaleOrder>();
                if (PAState == "Yes")
                {
                    ent.PAState  = "待审核";
                    ent.PANumber = DataHelper.QueryValue("select " + db + ".dbo.fun_getPriceAppNumber()") + "";
                }
                else
                {
                    ent.PAState  = "";
                    ent.PANumber = "";
                }

                ent.DoUpdate();

                //处理OrdersPart表
                //删除
                OrdersPart.DeleteAll("OId='" + ent.Id + "'");
                //添加
                InsertProPart(ent, strList);

                //创建价格申请单
                if (PAState == "Yes")
                {
                    CreatePriceApply(ent);
                }

                #region  除出库单表并更新销售单状态

                if (RequestData.Get <string>("del") == "yes")
                {
                    DeliveryOrder[] dorders = DeliveryOrder.FindAllByProperty("PId", ent.Id);
                    foreach (DeliveryOrder dorder in dorders)
                    {
                        DelieryOrderPart.DeleteAll("DId='" + dorder.Id + "'");
                        DeliveryOrder.DeleteAll("Id='" + dorder.Id + "'");
                    }

                    //更新出库单状态
                    OrdersPart[] ops = OrdersPart.FindAllByProperty("OId", ent.Id);
                    foreach (OrdersPart opt in ops)
                    {
                        if (opt != null)
                        {
                            opt.OutCount = 0;
                            opt.DoSave();
                        }
                    }

                    //更新order的json
                    string jsons = "";
                    ops = OrdersPart.FindAllByProperty("OId", ent.Id);
                    foreach (OrdersPart opt in ops)
                    {
                        jsons += "{";
                        jsons += "Id:'" + opt.PId + "',";
                        jsons += "Isbn:'" + opt.Isbn + "',";
                        jsons += "Code:'" + opt.PCode + "',";
                        jsons += "Name:'" + opt.PName + "',";
                        jsons += "Unit:'" + opt.Unit + "',";
                        jsons += "MinSalePrice:'" + opt.MinSalePrice + "',";
                        jsons += "Price:'" + opt.SalePrice + "',";
                        jsons += "Amount:'" + opt.Amount + "',";
                        jsons += "Count:'" + opt.Count + "',";
                        jsons += "OutCount:'" + opt.OutCount + "',";
                        jsons += "Remark:'" + opt.Remark + "'";
                        jsons += "},";
                    }

                    string count = DataHelper.QueryValue("select count(1) from " + db + "..OrdersPart where OId='" + ent.Id + "' and OutCount=[Count]") + "";
                    if (count == "0")
                    {
                        ent.DeliveryState = "";
                    }
                    else
                    {
                        ent.DeliveryState = "部分生成出库单";
                    }

                    ent.Child = "[" + jsons.Substring(0, jsons.Length - 1) + "]";
                    ent.DoUpdate();
                }
                #endregion

                this.SetMessage("修改成功!");
                break;

            case RequestActionEnum.Insert:
            case RequestActionEnum.Create:
                ent = this.GetPostedData <SaleOrder>();
                if (PAState == "Yes")
                {
                    ent.PAState  = "待审核";
                    ent.PANumber = DataHelper.QueryValue("select " + db + ".dbo.fun_getPriceAppNumber()") + "";
                }
                ent.PId = paid;

                //自动生成流水号
                ent.Number = DataHelper.QueryValue("select " + db + ".dbo.fun_getOrderNumber()") + "";

                ent.DoCreate();

                //处理OrdersPart表
                //添加

                InsertProPart(ent, strList);

                //创建价格申请单
                if (PAState == "Yes")
                {
                    CreatePriceApply(ent);
                }

                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <SaleOrder>();
                ent.DoDelete();
                this.SetMessage("删除成功!");
                return;

            default:
                if (RequestActionString == "submitfinish")
                {
                    SaleOrder pc = SaleOrder.Find(this.RequestData.Get <string>("id"));
                    pc.State         = "End";
                    pc.DeliveryState = "已生成出库单";
                    pc.ApprovalState = this.RequestData.Get <string>("ApprovalState");
                    pc.Save();

                    //自动生成发货单
                    if (pc.ApprovalState == "同意")
                    {
                        DeliveryOrder dor = new DeliveryOrder
                        {
                            Child         = pc.Child,
                            CId           = pc.Id,
                            WarehouseId   = pc.WarehouseId,
                            WarehouseName = pc.WarehouseName,
                            CName         = pc.CName,
                            CreateId      = UserInfo.UserID,
                            CreateName    = UserInfo.Name,
                            CreateTime    = DateTime.Now,
                            ExpectedTime  = pc.ExpectedTime,
                            Number        = DateTime.Now.ToString("yyyyMMddHHmmss")
                        };
                        dor.DoCreate();
                    }
                }
                else if (RequestActionString == "inputexcel")
                {
                    string path  = @"D:\RW\Files\AppFiles\Portal\Default\" + RequestData.Get <string>("path");
                    string strcn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';";    //连接字符串

                    #region 遍历整个excel
                    //DataSet ds = GetDataFromExcel(path);

                    ////遍历DataSet取数据

                    ////清除无效行
                    //ds.Tables[0].Rows.RemoveAt(0);
                    //ds.Tables[0].Rows.RemoveAt(0);
                    //ds.Tables[0].Rows.RemoveAt(0);
                    //PageState.Add("error", "Tables:" + ds.Tables.Count + " Table[0]:" + ds.Tables[0].Select("F4 <> ''").Length + "数量" + ds.Tables[0].Rows[0][3]);

                    //return;
                    #endregion

                    #region old
                    try
                    {
                        string           sql  = "select * from [Sheet1$]";
                        OleDbDataAdapter oldr = new OleDbDataAdapter(sql, strcn);    //读取数据,并填充到DATASET里
                        DataTable        dt   = new DataTable();
                        oldr.Fill(dt);

                        if (dt.Rows.Count > 0)
                        {
                            string strjson = RequestData.Get <string>("json").Replace("[]", "");
                            if (strjson.Length > 0)
                            {
                                strjson = strjson.Substring(1, strjson.Length - 2) + ",";
                            }
                            DataRow row = null;
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                row = dt.Rows[i];

                                strjson += "{";
                                strjson += "Id:'" + row["Id"] + "',";
                                strjson += "Isbn:'" + row["Isbn"] + "',";
                                strjson += "Code:'" + row["Code"] + "',";
                                strjson += "Name:'" + row["Name"] + "',";
                                strjson += "Unit:'" + row["Unit"] + "',";
                                strjson += "MinSalePrice:'" + row["MinSalePrice"] + "',";
                                strjson += "Price:'" + row["MinSalePrice"] + "',";
                                strjson += "Amount:'" + row["Amount"] + "',";
                                strjson += "Count:'" + row["Count"] + "',";
                                strjson += "Remark:'" + row["Remark"] + "'";
                                strjson += "},";
                            }
                            if (strjson != "")
                            {
                                strjson = "[" + strjson.Substring(0, strjson.Length - 1) + "]";
                                PageState.Add("result", strjson);
                            }
                        }
                        return;
                    }
                    catch (Exception ex)
                    {
                        PageState.Add("error", ex.Message);
                        return;
                    }
                    #endregion
                }
                else if (RequestActionString == "updateAmount")
                {
                    SaleOrder o          = SaleOrder.TryFind(id);
                    string    TotalMoney = RequestData.Get <string>("TotalMoney");
                    o.DiscountAmount = RequestData.Get <decimal>("DiscountAmount");
                    o.TotalMoney     = Convert.ToDecimal(TotalMoney);
                    o.DoUpdate();
                }
                break;
            }

            if (RequestActionString == "getSalesman")
            {
                string   cid      = RequestData.Get <string>("CId");
                Customer customer = Customer.Find(cid);
                if (customer != null)
                {
                    PageState.Add("Code", customer.Code);
                    PageState.Add("SaleUser", customer.MagUser);
                    PageState.Add("SaleUserId", customer.MagId);
                }
            }
            else if (op == "c" && !string.IsNullOrEmpty(paid))
            {
                if (!string.IsNullOrEmpty(paid))
                {
                    PriceApply paent = PriceApply.TryFind(paid);
                    if (paent != null)
                    {
                        paent.Reason        = "";
                        paent.ApprovalState = "";
                        paent.ExpectedTime  = null;
                        paent.Id            = "";
                        paent.Number        = "";
                        paent.Remark        = "";
                        paent.State         = "";
                        this.SetFormData(paent);
                    }
                }
            }
            else if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ent = SaleOrder.Find(id);
                }

                this.SetFormData(ent);
                this.PageState.Add("State", ent.State);

                //查询子商品
                string sql = "select Id, PId, PCode as Code, PName as Name, Isbn, Count, Unit, MinSalePrice, SalePrice as Price, Amount,CustomerOrderNo, Remark, OutCount,BillingCount from " + db + "..OrdersPart where OId='" + id + "'";
                PageState.Add("DetailList", DataHelper.QueryDictList(sql));
            }

            this.PageState.Add("FlowEnum", SysEnumeration.GetEnumDictList("WorkFlow.Simple"));

            PageState.Add("InvoiceType", SysEnumeration.GetEnumDict("InvoiceType"));
            PageState.Add("DeliveryMode", SysEnumeration.GetEnumDict("DeliveryMode"));
            PageState.Add("PayType", SysEnumeration.GetEnumDict("PayType"));
            PageState.Add("CalculateManner", SysEnumeration.GetEnumDict("CalculateManner"));
        }
Exemplo n.º 8
0
        private void DoBatchDelete()
        {
            IList <object> idList = RequestData.GetList <object>("IdList");
            string         db     = ConfigurationManager.AppSettings["ExamineDB"];

            if (idList != null && idList.Count > 0)
            {
                OrdersPart         op     = null;
                OrdersPart[]       ops    = null;
                DelieryOrderPart[] dops   = null;
                DeliveryOrder      dorder = null;
                SaleOrder          order  = null;
                string             count  = "";

                //更新订单状态,同时删除DeliveryOrderPart表数据
                foreach (object obj in idList)
                {
                    dorder = DeliveryOrder.TryFind(obj);
                    if (dorder == null)
                    {
                        DelieryOrderPart.DeleteAll("DId='" + obj + "'"); //删除DeliveryOrderPart
                        continue;
                    }

                    dops = DelieryOrderPart.FindAllByProperty("DId", obj);
                    foreach (DelieryOrderPart dop in dops)
                    {
                        //更新订单状态
                        op = OrdersPart.TryFind(dop.PId);
                        if (op != null)
                        {
                            op.OutCount = (op.OutCount == null ? 0 : Convert.ToInt32(op.OutCount)) - Convert.ToInt32(dop.Count);
                            op.DoSave();
                        }
                    }

                    //更新order的json
                    string jsons = "";
                    order = SaleOrder.FindAllByProperty("Id", dorder.PId).FirstOrDefault <SaleOrder>();
                    if (order == null)
                    {
                        DelieryOrderPart.DeleteAll("DId='" + obj + "'"); //删除DeliveryOrderPart
                        continue;
                    }
                    ops = OrdersPart.FindAllByProperty("OId", order.Id);
                    //拼json
                    foreach (OrdersPart opt in ops)
                    {
                        jsons += "{";
                        jsons += "Id:'" + opt.PId + "',";
                        jsons += "Isbn:'" + opt.Isbn + "',";
                        jsons += "Code:'" + opt.PCode + "',";
                        jsons += "Name:'" + opt.PName + "',";
                        jsons += "Unit:'" + opt.Unit + "',";
                        jsons += "MinSalePrice:'" + opt.MinSalePrice + "',";
                        jsons += "Price:'" + opt.SalePrice + "',";
                        jsons += "Amount:'" + opt.Amount + "',";
                        jsons += "Count:'" + opt.Count + "',";
                        jsons += "OutCount:'" + opt.OutCount + "',";
                        jsons += "Remark:'" + opt.Remark + "'";
                        jsons += "},";
                    }

                    count = DataHelper.QueryValue("select count(1) from " + db + "..OrdersPart where OId='" + order.Id + "' and OutCount=[Count]") + "";
                    if (count == "0")
                    {
                        order.DeliveryState = "";
                    }
                    else
                    {
                        order.DeliveryState = "部分生成出库单";
                    }

                    order.Child = "[" + jsons.Substring(0, jsons.Length - 1) + "]";
                    order.DoSave();

                    DelieryOrderPart.DeleteAll("DId='" + obj + "'"); //删除DeliveryOrderPart
                }

                DeliveryOrder.DoBatchDelete(idList.ToArray());
            }
        }
Exemplo n.º 9
0
        private void CreateLog()
        {
            IList <InWarehouseDetailDetail> iwddEnts = InWarehouseDetailDetail.FindAll();//入库

            foreach (InWarehouseDetailDetail iwddEnt in iwddEnts)
            {
                StockLog    slEnt = new StockLog();
                InWarehouse iwEnt = null;
                if (!string.IsNullOrEmpty(iwddEnt.InWarehouseDetailId))
                {
                    slEnt.InOrOutDetailId = iwddEnt.InWarehouseDetailId;
                    InWarehouseDetail iwdEnt = InWarehouseDetail.Find(iwddEnt.InWarehouseDetailId);
                    iwEnt = InWarehouse.Find(iwdEnt.InWarehouseId);
                }
                else
                {
                    slEnt.InOrOutDetailId = iwddEnt.OtherInWarehouseDetailId;
                    OtherInWarehouseDetail oiwdEnt = OtherInWarehouseDetail.Find(iwddEnt.OtherInWarehouseDetailId);
                    iwEnt = InWarehouse.Find(oiwdEnt.InWarehouseId);
                }
                slEnt.InOrOutBillNo = iwEnt.InWarehouseNo;
                slEnt.OperateType   = "产品入库";
                slEnt.WarehouseId   = iwEnt.WarehouseId;
                slEnt.WarehouseName = iwEnt.WarehouseName;
                //IList<StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, iwddEnt.ProductId, StockInfo.Prop_WarehouseId, iwEnt.WarehouseId);
                //if (siEnts.Count > 0)
                //{
                //    slEnt.StockQuantity = siEnts[0].StockQuantity;
                //}
                slEnt.Quantity  = iwddEnt.Quantity;
                slEnt.ProductId = iwddEnt.ProductId;
                Product pEnt = Product.TryFind(iwddEnt.ProductId);
                if (pEnt != null)
                {
                    slEnt.ProductName = pEnt.Name;
                    slEnt.ProductCode = pEnt.Code;
                    slEnt.ProductIsbn = pEnt.Isbn;
                    slEnt.ProductPcn  = pEnt.Pcn;
                    slEnt.CreateId    = iwddEnt.CreateId;
                    slEnt.CreateName  = iwddEnt.CreateName;
                    slEnt.CreateTime  = iwddEnt.CreateTime;
                    slEnt.DoCreate();
                }
            }
            //生成出库日志
            IList <DelieryOrderPart> dopEnts = DelieryOrderPart.FindAllByProperty(DelieryOrderPart.Prop_State, "已出库");

            foreach (DelieryOrderPart dopEnt in dopEnts)
            {
                StockLog slEnt = new StockLog();
                slEnt.InOrOutDetailId = dopEnt.Id;
                DeliveryOrder doEnt = DeliveryOrder.Find(dopEnt.DId);
                slEnt.InOrOutBillNo = doEnt.Number;
                slEnt.OperateType   = "产品出库";
                slEnt.WarehouseId   = doEnt.WarehouseId;
                slEnt.WarehouseName = doEnt.WarehouseName;
                //IList<StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, iwddEnt.ProductId, StockInfo.Prop_WarehouseId, iwEnt.WarehouseId);
                //if (siEnts.Count > 0)
                //{
                //    slEnt.StockQuantity = siEnts[0].StockQuantity;
                //}
                slEnt.Quantity = dopEnt.OutCount;
                if (!string.IsNullOrEmpty(dopEnt.ProductId))
                {
                    slEnt.ProductId = dopEnt.ProductId;
                    Product pEnt = Product.TryFind(dopEnt.ProductId);
                    if (pEnt != null)
                    {
                        slEnt.ProductName = pEnt.Name;
                        slEnt.ProductCode = pEnt.Code;
                        slEnt.ProductIsbn = pEnt.Isbn;
                        slEnt.ProductPcn  = pEnt.Pcn;
                        slEnt.CreateId    = dopEnt.CreateId;
                        slEnt.CreateName  = dopEnt.CreateName;
                        slEnt.CreateTime  = dopEnt.CreateTime;
                        slEnt.DoCreate();
                    }
                }
            }
            //盘点操作库存日志
            string sql = "select * from SHHG_AimExamine..StockCheckDetail where StockCheckResult!='正常' and StockCheckState='盘点结束'";
            IList <EasyDictionary> scdDics = DataHelper.QueryDictList(sql);

            foreach (EasyDictionary scdDic in scdDics)
            {
                StockLog slEnt = new StockLog();
                slEnt.InOrOutDetailId = scdDic.Get <string>("Id");
                StockCheck scEnt = StockCheck.Find(scdDic.Get <string>("StockCheckId"));
                slEnt.InOrOutBillNo = scEnt.StockCheckNo;
                slEnt.OperateType   = "库存盘点";
                slEnt.WarehouseId   = scEnt.WarehouseId;
                slEnt.WarehouseName = scEnt.WarehouseName;
                slEnt.StockQuantity = scdDic.Get <Int32>("StockQuantity");
                slEnt.Quantity      = scdDic.Get <Int32>("StockCheckQuantity") - scdDic.Get <Int32>("StockQuantity");
                slEnt.ProductId     = scdDic.Get <string>("ProductId");
                Product pEnt = Product.TryFind(slEnt.ProductId);
                if (pEnt != null)
                {
                    slEnt.ProductName = pEnt.Name;
                    slEnt.ProductCode = pEnt.Code;
                    slEnt.ProductIsbn = pEnt.Isbn;
                    slEnt.ProductPcn  = pEnt.Pcn;
                    slEnt.CreateId    = scEnt.CreateId;
                    slEnt.CreateName  = scEnt.CreateName;
                    slEnt.CreateTime  = scEnt.CreateTime;
                    slEnt.DoCreate();
                }
            }
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string db = ConfigurationManager.AppSettings["ExamineDB"];

            op   = RequestData.Get <string>("op");
            id   = RequestData.Get <string>("id");
            type = RequestData.Get <string>("type");
            DeliveryOrder  ent     = null;
            IList <string> strList = RequestData.GetList <string>("data");

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                ent = this.GetMergedData <DeliveryOrder>();
                if (type == "xg")
                {
                    ent.DoUpdate();
                }
                else if (type == "ck")
                {
                    UpdateStockInfo(strList, ent);      //更新库存及唯一编号
                    if (ent.DeliveryType == "换货出库")
                    {
                        ChangeProduct dorder = ChangeProduct.TryFind(ent.PId);
                        if (dorder != null)
                        {
                            if ((dorder.State + "").Contains("已入库"))
                            {
                                dorder.State = "已完成";
                            }
                            else
                            {
                                dorder.State += ",仓库已出库:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                            }
                            dorder.DoSave();
                        }
                    }
                    //更新子商品信息(先删除,再添加)
                    DelieryOrderPart.DeleteAll("DId='" + ent.Id + "'");     //删除DeliveryOrderPart
                    //添加出库商品信息并更新出库单状态
                    ent.State = InsertPart(strList, ent.Id);
                    ent.DoUpdate();
                    if (ent.DeliveryType == "调拨出库")    //add by phg 20120519 跟出库单的状态保持一致
                    {
                        WarehouseExchange weEnt = WarehouseExchange.Find(ent.PId);
                        weEnt.OutWarehouseState = ent.State;
                        weEnt.DoUpdate();
                    }
                    //更新SaleOrder表出库状态
                    DataHelper.ExecSql("update " + db + "..SaleOrders set DeState=" + db + ".dbo.fun_getDeliveryState(Id) where id='" + ent.PId + "'");
                }
                break;

            default:
                break;
            }
            if (RequestActionString == "getSalesman")
            {
                string   cid      = RequestData.Get <string>("CId");
                Customer customer = Customer.Find(cid);
                if (customer != null)
                {
                    PageState.Add("MagUser", customer.MagUser);
                    PageState.Add("MagId", customer.MagId);
                    PageState.Add("Address", customer.Address);
                    // PageState.Add("Tel", customer.Tel);
                    PageState.Add("Code", customer.Code);
                }
            }
            //根据压缩机唯一Id获取压缩机条码
            else if (RequestActionString == "getprobyguid")
            {
                //string isbn = DataHelper.QueryValue("select ModelNo from " + db + "..Compressor where SeriesNo='" + RequestData.Get<string>("isbn") + "'") + "";

                string isbn = DataHelper.QueryValue("select ModelNo from " + db + "..v_Compressor where SeriesNo='" + RequestData.Get <string>("Guid") + "' and ([State] is null or [State]<>'已出库')") + "";
                PageState.Add("isbn", isbn);
            }
            //获取压缩机整版的数量及GUIDS
            else if (RequestActionString == "getprobyboxnum")
            {
                string boxnum = RequestData.Get <string>("boxnum");
                string isbn   = DataHelper.QueryValue("select ModelNo from " + db + "..v_Compressor where SkinNo='" + boxnum + "' and ([State] is null or [State]<>'已出库')") + "";
                string count  = DataHelper.QueryValue("select count(1) from " + db + "..v_Compressor where SkinNo='" + boxnum + "' and ([State] is null or [State]<>'已出库')") + "";
                string guids  = DataHelper.QueryValue("select " + db + ".dbo.fun_getGuids('" + boxnum + "')") + "";

                PageState.Add("isbn", isbn);
                PageState.Add("count", count);
                PageState.Add("guids", guids);
            }
            //获取配件箱子所包含的配件数量
            else if (RequestActionString == "getPJbyboxnum")
            {
                string boxnum = RequestData.Get <string>("boxnum");
                sql = "select * from SHHG_AimExamine..Products where FirstSkinIsbn='" + boxnum + "' and FirstSkinCapacity is not null";
                IList <EasyDictionary> dics = DataHelper.QueryDictList(sql);
                if (dics.Count > 0)
                {
                    PageState.Add("isbn", dics[0].Get <string>("Isbn"));
                    PageState.Add("count", dics[0].Get <int>("FirstSkinCapacity"));
                }
                sql  = "select * from SHHG_AimExamine..Products where SecondSkinIsbn='" + boxnum + "' and SecondSkinCapacity is not null";
                dics = DataHelper.QueryDictList(sql);
                if (dics.Count > 0)
                {
                    PageState.Add("isbn", dics[0].Get <string>("Isbn"));
                    PageState.Add("count", dics[0].Get <int>("SecondSkinCapacity"));
                }
            }
            else if (RequestActionString == "getguids")
            {
                string guids = DataHelper.QueryValue("select " + db + ".dbo.fun_getGuids('" + RequestData.Get <string>("SkinNo") + "'," + RequestData.Get <string>("Count") + ")") + "";
                PageState.Add("guids", guids);
            }
            else if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ent = DeliveryOrder.Find(id);
                }
                SetFormData(ent);
                PageState.Add("State", ent.State);
                //查询子商品
                sql = "select p.Id, PId, PCode as Code, ProductId, PName as Name, c.ProductType, p.Isbn, Guids, Count,Count-(isnull(OutCount,0)) as dck, isnull(OutCount,0) as OutCount, p.Unit, p.Remark, FirstSkinIsbn,Count*(c.Weight) as TotalWeight," + db + ".dbo.fun_getProQuantity(ProductId) as StockQuan," + db + ".dbo.fun_getProQuantityByWarehouseId(ProductId,'" + ent.WarehouseId + "') as BenStockQuan from " + db + "..DelieryOrderPart p "
                      + " left join " + db + "..Products c on c.Id=p.ProductId  where DId='" + id + "'";
                PageState.Add("DetailList", DataHelper.QueryDictList(sql));
            }
            PageState.Add("DeliveryMode", SysEnumeration.GetEnumDict("DeliveryMode"));
        }