Beispiel #1
0
        private void ProcessDetail(InWarehouse iwEnt)
        {
            ropEnts = ReturnOrderPart.FindAllByProperty(ReturnOrderPart.Prop_ReturnOrderId, id);
            foreach (ReturnOrderPart ropEnt in ropEnts)
            {
                ropEnt.DoDelete();
            }
            IList <string> entStrList = RequestData.GetList <string>("data");

            ropEnts = entStrList.Select(tent => JsonHelper.GetObject <ReturnOrderPart>(tent) as ReturnOrderPart).ToList();
            foreach (ReturnOrderPart ropEnt in ropEnts)
            {
                ropEnt.ReturnOrderId = ent.Id;
                ropEnt.DoCreate();
                OrdersPart opEnt = OrdersPart.Find(ropEnt.OrderPartId);//更新销售单明细的退货数量
                opEnt.ReturnCount = (opEnt.ReturnCount.HasValue ? opEnt.ReturnCount : 0) + ropEnt.Count;
                opEnt.DoUpdate();
                OtherInWarehouseDetail oidEnt = new OtherInWarehouseDetail();//创建入库单明细
                oidEnt.InWarehouseId    = iwEnt.Id;
                oidEnt.ProductId        = ropEnt.ProductId;
                oidEnt.ProductName      = ropEnt.ProductName;
                oidEnt.ProductCode      = ropEnt.ProductCode;
                oidEnt.ProductISBN      = ropEnt.Isbn;
                oidEnt.ProductType      = Product.Find(ropEnt.ProductId).ProductType;
                oidEnt.Quantity         = ropEnt.Count;
                oidEnt.InWarehouseState = "未入库";
                oidEnt.Remark           = ropEnt.Remark;
                oidEnt.DoCreate();
            }
        }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (RequestActionString == "submit")
     {
         StartFlow();
     }
     else if (RequestActionString == "AutoExecuteFlow")
     {
         Task task = Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, this.RequestData.Get <string>("FlowId"))[0];
         //自动执行,关键代码
         Aim.WorkFlow.WorkFlow.AutoExecute(task);
         this.PageState.Add("TaskId", task.ID);
     }
     else if (RequestActionString == "batchdelete")
     {
         DoBatchDelete();
     }
     else if (RequestData.Get <string>("optype") == "getChildData")
     {
         string       oid = RequestData.Get <string>("OId");
         OrdersPart[] ops = OrdersPart.FindAllByProperties("OId", oid);
         PageState.Add("DetailList", ops);
     }
     else
     {
         DoSelect();
     }
 }
        private void ProcessDetail()
        {
            IList <OrderInvoiceDetail> oidEnts = OrderInvoiceDetail.FindAllByProperty("OrderInvoiceId", ent.Id);

            foreach (OrderInvoiceDetail oidEnt in oidEnts)
            {
                oidEnt.DoDelete();
            }
            oidEnts = entStrList.Select(tent => JsonHelper.GetObject <OrderInvoiceDetail>(tent) as OrderInvoiceDetail).ToList();
            foreach (OrderInvoiceDetail oidEnt in oidEnts)
            {
                oidEnt.OrderInvoiceId = ent.Id;
                oidEnt.DoCreate();
                OrdersPart opEnt = OrdersPart.Find(oidEnt.OrderDetailId);
                opEnt.BillingCount = (opEnt.BillingCount.HasValue ? opEnt.BillingCount : 0) + oidEnt.InvoiceCount;//顺便更新订单明细的开票数量
                opEnt.DoUpdate();
            }
            string[] orderIdArray = orderids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string str in orderIdArray)//更新涉及订单的开票状态
            {
                sql = @"select count(Id) from SHHG_AimExamine..OrdersPart where OId='" + str + "' and Count-isnull(ReturnCount,0)<>isnull(BillingCount,0)";
                SaleOrder soEnt = SaleOrder.Find(str);
                if (DataHelper.QueryValue <int>(sql) == 0)
                {
                    soEnt.InvoiceState = "已全部开发票";
                }
                else
                {
                    soEnt.InvoiceState = "已部分开发票";
                }
                soEnt.DoUpdate();
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CC = RequestData.Get <string>("CC");
            string ids = RequestData.Get <string>("ids");

            switch (RequestActionString)
            {
            case "ResetSaleOrderDetail":
                if (!string.IsNullOrEmpty(ids))
                {
                    string[] idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string oid in idArray)
                    {
                        IList <OrdersPart> opEnts = OrdersPart.FindAllByProperty(OrdersPart.Prop_OId, oid);
                        foreach (OrdersPart opEnt in opEnts)
                        {
                            opEnt.BillingCount = null;
                            opEnt.DoUpdate();
                        }
                        soEnt = SaleOrder.Find(oid);
                        soEnt.InvoiceState = null;
                        soEnt.DoUpdate();
                    }
                }
                break;

            case "SetReceiptModel":
                if (!string.IsNullOrEmpty(ids))
                {
                    string[] idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < idArray.Length; i++)
                    {
                        soEnt             = SaleOrder.Find(idArray[i]);
                        soEnt.InvoiceType = "收据";
                        soEnt.DoUpdate();
                    }
                }
                break;

            case "DelayInvoice":
                if (!string.IsNullOrEmpty(ids))
                {
                    string[] idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < idArray.Length; i++)
                    {
                        soEnt       = SaleOrder.Find(idArray[i]);
                        soEnt.State = "暂缓开票";
                        soEnt.DoUpdate();
                    }
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op");
            id = RequestData.Get <string>("id");
            if (!string.IsNullOrEmpty(id))
            {
                ent = ReturnOrder.Find(id);
            }
            switch (RequestActionString)
            {
            case "update":
                ent = GetMergedData <ReturnOrder>();
                ent.DoUpdate();
                break;

            case "create":
                ent        = this.GetPostedData <ReturnOrder>();
                ent.Number = DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getReturnOrderNumber()") + "";     //自动生成流水号
                ent.State  = "已生成";
                ent.DoCreate();
                soent = SaleOrder.FindAllByProperty("Number", ent.OrderNumber).FirstOrDefault <SaleOrder>();
                soent.ReturnAmount = (soent.ReturnAmount.HasValue ? soent.ReturnAmount.Value : 0) + ent.ReturnMoney;
                soent.DoUpdate();    //将退货金额反写到销售单
                if (soent.InvoiceState == "已全部开发票")
                {
                    ent.IsDiscount = "T";
                    ent.DoUpdate();
                }
                InWarehouse inwh = new InWarehouse
                {
                    PublicInterface = ent.Id,                   //退货单Id
                    InWarehouseNo   = DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getInWarehouseNo()").ToString(),
                    InWarehouseType = "退货入库",
                    WarehouseId     = ent.WarehouseId,
                    WarehouseName   = ent.WarehouseName,
                    State           = "未入库"
                };
                inwh.DoCreate();
                ProcessDetail(inwh);
                break;

            case "GetSaleOrderPart":
                string orderNumber = RequestData.Get <string>("OrderNumber");
                soent = SaleOrder.FindAllByProperty("Number", orderNumber).FirstOrDefault <SaleOrder>();
                PageState.Add("Result", OrdersPart.FindAllByProperty(OrdersPart.Prop_OId, soent.Id));
                break;

            default:
                DoSelect();
                break;
            }
        }
Beispiel #6
0
 //添加子商品
 private void InsertProPart(SaleOrder ent)
 {
     for (int i = 0; i < objarr.Length; i++)
     {
         if (objarr.Length == 1)
         {
             dic = FromJson(objarr[i]) as Dictionary <string, object>;
         }
         else
         {
             if (i == 0)
             {
                 dic = FromJson(objarr[i] + "}") as Dictionary <string, object>;
             }
             else if (i == objarr.Length - 1)
             {
                 dic = FromJson("{" + objarr[i]) as Dictionary <string, object>;
             }
             else
             {
                 dic = FromJson("{" + objarr[i] + "}") as Dictionary <string, object>;
             }
         }
         if (dic != null)
         {
             //一个一个的添加
             entPart = new OrdersPart
             {
                 OId          = ent.Id,
                 PId          = dic["Id"] + "",
                 PName        = dic["Name"] + "",
                 PCode        = dic["Code"] + "",
                 Isbn         = dic["Isbn"] + "",
                 MinSalePrice = dic.ContainsKey("MinSalePrice") ? (decimal?)Convert.ToDecimal(dic["MinSalePrice"]) : null,
                 SalePrice    = dic.ContainsKey("Price") ? (decimal?)Convert.ToDecimal(dic["Price"]) : null,
                 Amount       = dic.ContainsKey("Amount") ? (decimal?)Convert.ToDecimal(dic["Amount"]) : null,
                 Unit         = dic.ContainsKey("Unit") ? dic["Unit"] + "" : null,
                 Count        = dic.ContainsKey("Count") ? (int?)Convert.ToInt32(dic["Count"]) : null,
                 Remark       = dic.ContainsKey("Remark") ? dic["Remark"] + "" : "",
                 IsValid      = true,
                 Guids        = dic.ContainsKey("Guids") ? dic["Guids"] + "" : "",
                 CreateId     = UserInfo.UserID,
                 CreateName   = UserInfo.Name,
                 CreateTime   = DateTime.Now
             };
             entPart.DoCreate();
         }
     }
 }
Beispiel #7
0
        private void DoBatchDelete()
        {
            IList <object> idList = RequestData.GetList <object>("IdList");

            if (idList != null && idList.Count > 0)
            {
                SaleOrder.DoBatchDelete(idList.ToArray());

                //删除对应的商品信息防止产生垃圾数据
                foreach (string oid in idList)
                {
                    OrdersPart.DeleteAll("OId='" + oid + "'");
                }
            }
        }
Beispiel #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (RequestActionString == "batchdelete")
     {
         DoBatchDelete();
     }
     else if (RequestData.Get <string>("optype") == "getChildData")
     {
         string       oid = RequestData.Get <string>("OId");
         OrdersPart[] ops = OrdersPart.FindAllByProperties("OId", oid);
         PageState.Add("DetailList", ops);
     }
     else
     {
         DoSelect();
     }
 }
Beispiel #9
0
        //添加子商品
        private void InsertProPart(SaleOrder ent, IList <string> strList)
        {
            for (int i = 0; i < strList.Count; i++)
            {
                dic = FromJson(strList[i]) as Dictionary <string, object>;

                if (dic != null)
                {
                    //一个一个的添加
                    entPart = new OrdersPart
                    {
                        OId             = ent.Id,
                        PId             = dic["PId"] + "",
                        PName           = dic["Name"] + "",
                        PCode           = dic["Code"] + "",
                        Isbn            = dic.ContainsKey("Isbn") ? dic["Isbn"] + "" : "",
                        MinSalePrice    = dic.ContainsKey("MinSalePrice") && dic["MinSalePrice"] + "" != "" ? (decimal?)Convert.ToDecimal(dic["MinSalePrice"]) : null,
                        SalePrice       = dic.ContainsKey("Price") && dic["Price"] + "" != "" ? (decimal?)Convert.ToDecimal(dic["Price"]) : null,
                        Amount          = dic.ContainsKey("Amount") && dic["Amount"] + "" != "NaN" ? (decimal?)Convert.ToDecimal(dic["Amount"]) : null,
                        Unit            = dic.ContainsKey("Unit") ? dic["Unit"] + "" : null,
                        Count           = dic.ContainsKey("Count") && dic["Count"] + "" != "" ? (int?)Convert.ToInt32(dic["Count"]) : null,
                        OutCount        = dic.ContainsKey("OutCount") && dic["OutCount"] + "" != "" ? (int?)Convert.ToInt32(dic["OutCount"]) : null,
                        CustomerOrderNo = dic.ContainsKey("CustomerOrderNo") ? dic["CustomerOrderNo"] + "" : "",
                        Remark          = dic.ContainsKey("Remark") ? dic["Remark"] + "" : "",
                        IsValid         = true,
                        Guids           = dic.ContainsKey("Guids") ? dic["Guids"] + "" : "",
                        CreateId        = UserInfo.UserID,
                        CreateName      = UserInfo.Name,
                        CreateTime      = ent.CreateTime
                    };
                    //entPart.OId = ent.Id;
                    //entPart.PId = dic["PId"] + "";
                    //entPart.MinSalePrice = dic.ContainsKey("MinSalePrice") && dic["MinSalePrice"] + "" != "" ? (decimal?)Convert.ToDecimal(dic["MinSalePrice"]) : null;
                    //entPart.SalePrice = dic.ContainsKey("Price") && dic["Price"] + "" != "" ? (decimal?)Convert.ToDecimal(dic["Price"]) : null;
                    //if (dic.ContainsKey("Amount"))
                    //{
                    //    entPart.Amount = Convert.ToDecimal(dic["Amount"]);
                    //}
                    entPart.DoCreate();
                }
            }
        }
Beispiel #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id = RequestData.Get <string>("id");
            if (!string.IsNullOrEmpty(id))
            {
                roEnt = ReturnOrder.Find(id);
            }
            switch (RequestActionString)
            {
            case "delete":
                //先删除入库单及入库明细
                InWarehouse iwEnt = InWarehouse.FindAllByProperty(InWarehouse.Prop_PublicInterface, roEnt.Id).FirstOrDefault <InWarehouse>();
                IList <OtherInWarehouseDetail> oiwdEnts = OtherInWarehouseDetail.FindAllByProperty(OtherInWarehouseDetail.Prop_InWarehouseId, iwEnt.Id);
                foreach (OtherInWarehouseDetail oiwdEnt in oiwdEnts)
                {
                    oiwdEnt.DoDelete();
                }
                iwEnt.DoDelete();
                //更新销售单及销售明细
                SaleOrder soEnt = SaleOrder.FindAllByProperty(SaleOrder.Prop_Number, roEnt.OrderNumber).FirstOrDefault <SaleOrder>();
                soEnt.ReturnAmount = (soEnt.ReturnAmount.HasValue ? soEnt.ReturnAmount.Value : 0) - (roEnt.ReturnMoney.HasValue ? roEnt.ReturnMoney.Value : 0);
                soEnt.DoUpdate();
                IList <ReturnOrderPart> ropEnts = ReturnOrderPart.FindAllByProperty(ReturnOrderPart.Prop_ReturnOrderId, roEnt.Id);
                foreach (ReturnOrderPart ropEnt in ropEnts)
                {
                    OrdersPart opEnt = OrdersPart.Find(ropEnt.OrderPartId);
                    opEnt.ReturnCount = (opEnt.ReturnCount.HasValue ? opEnt.ReturnCount.Value : 0) - ropEnt.Count;
                    opEnt.DoUpdate();
                    ropEnt.DoDelete();
                }
                roEnt.DoDelete();
                break;

            default:
                DoSelect();
                break;
            }
        }
        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());
            }
        }
Beispiel #12
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"));
        }
Beispiel #13
0
        string type = String.Empty; // 对象类型
        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");
            oid  = RequestData.Get <string>("oid");
            type = RequestData.Get <string>("type");
            PriceApply ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                ent               = this.GetMergedData <PriceApply>();
                ent.State         = "";
                ent.ApprovalState = "";
                ent.DoUpdate();
                this.SetMessage("修改成功!");
                break;

            case RequestActionEnum.Insert:
            case RequestActionEnum.Create:
                ent = this.GetPostedData <PriceApply>();
                if (oid != "")
                {
                    ent.OId = oid;
                }

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

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

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

            default:
                if (RequestActionString == "submitfinish")
                {
                    PriceApply pc = PriceApply.Find(this.RequestData.Get <string>("id"));
                    pc.State         = "End";
                    pc.ApprovalState = this.RequestData.Get <string>("ApprovalState");
                    pc.Save();

                    //更新销售单对应的状态
                    if (!string.IsNullOrEmpty(pc.OId))
                    {
                        SaleOrder order = SaleOrder.TryFind(pc.OId);
                        if (order != null)
                        {
                            order.PAState = pc.ApprovalState;
                            order.Save();
                        }
                    }
                }
                break;
            }
            if (RequestActionString == "getSalesman")
            {
                string   cid      = RequestData.Get <string>("CId");
                Customer customer = Customer.TryFind(cid);
                if (customer != null)
                {
                    PageState.Add("Code", customer.Code);
                }
            }
            else if (op == "c" && !string.IsNullOrEmpty(oid))
            {
                if (!string.IsNullOrEmpty(oid))
                {
                    SaleOrder order = SaleOrder.TryFind(oid);
                    if (order != null)
                    {
                        order.Id            = "";
                        order.Reason        = "";
                        order.Number        = "";
                        order.ApprovalState = "";
                        order.Remark        = "";
                        order.State         = "";
                        this.SetFormData(order);
                    }
                }
            }
            else if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ent = PriceApply.Find(id);
                }
                this.SetFormData(ent);
                this.PageState.Add("State", ent.State);
                IList <OrdersPart> opEnts = OrdersPart.FindAllByProperty(OrdersPart.Prop_OId, ent.OId);
                PageState.Add("DataList", opEnts);
            }
            PageState.Add("FlowEnum", SysEnumeration.GetEnumDictList("WorkFlow.Simple"));
        }
Beispiel #14
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;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                ent = this.GetMergedData <SaleOrder>();
                if (PAState == "Yes")
                {
                    ent.PAState  = "待审核";
                    ent.PANumber = "HGPA" + DateTime.Now.ToString("yyyyMMddHHmmss");
                }

                ent.DoUpdate();

                //处理OrdersPart表
                //删除
                OrdersPart.DeleteAll("OId='" + ent.Id + "'");
                //添加
                strjosn = ent.Child.Substring(1, ent.Child.Length - 2);
                objarr  = strjosn.Replace("},{", "#").Split('#');
                InsertProPart(ent);

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

                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表
                //添加
                strjosn = ent.Child.Substring(1, ent.Child.Length - 2);
                objarr  = strjosn.Replace("},{", "#").Split('#');
                InsertProPart(ent);

                //创建价格申请单
                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
                }
                break;
            }

            if (RequestActionString == "getSalesman")
            {
                string   cid      = RequestData.Get <string>("CId");
                Customer customer = Customer.Find(cid);
                if (customer != null)
                {
                    PageState.Add("Code", customer.Code);
                }
            }
            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);
            }

            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"));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string          action = Request["action"];
            Order_FenGongSi oEnt   = null;

            string where = "";
            string    sql = "";
            DataTable dt;
            string    obj  = "";
            string    json = "";
            IList <OrderDetail_FenGongSi> odEnts;
            string id = Request["id"];

            if (!string.IsNullOrEmpty(id))
            {
                oEnt = Order_FenGongSi.Find(id);
            }
            switch (action)
            {
            case "loadorderpart":
                string FenGongSiId = Request["fengongsiid"];
                string ProductCode = Request["ProductCode"];
                if (!string.IsNullOrEmpty(ProductCode))
                {
                    where += " and PCode like '%" + ProductCode + "%'";
                }
                sql = @"select a.Id,a.PId,a.PName,a.PCode,a.SalePrice,a.Count,isnull(a.SaleQuan,0) SaleQuan ,a.CreateTime,b.Number from SHHG_AimExamine..orderspart a  
                    left join SHHG_AimExamine..SaleOrders b on a.OId=b.Id where a.Count>isnull(a.SaleQuan,0) and cid='" + FenGongSiId + "'" + where;
                dt  = DataHelper.QueryDataTable(GetPageSql(sql));
                Response.Write("{total:" + totalProperty + ",rows:" + JsonHelper.GetJsonString(dt) + "}");
                Response.End();
                break;

            case "loadinvoicetype":
                sql = "select name from SHHG_AimPortal..SysEnumeration where ParentID='f6a3af59-85c0-4847-a2ff-aebdeadf1be7' order by SortIndex asc";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{rows:" + JsonHelper.GetJsonString(dt) + "}");
                Response.End();
                break;

            case "loadpaytype":
                sql = "select name from SHHG_AimPortal..SysEnumeration where ParentID='10404568-1e4f-4aab-95ff-86eeed6d955e' order by SortIndex asc";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{rows:" + JsonHelper.GetJsonString(dt) + "}");
                Response.End();
                break;

            case "loadcustomer":
                if (!string.IsNullOrEmpty(Request["name"]))
                {
                    where = " and Name like '%" + Request["name"] + "%'";
                }
                sql = "select id,name from SHHG_AimExamine..Customers where 1=1 " + where;
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "create":
                obj  = Request["data"];
                oEnt = JsonHelper.GetObject <Order_FenGongSi>(obj);
                oEnt.DoCreate();
                json   = Request["json"];
                odEnts = JsonHelper.GetObject <IList <OrderDetail_FenGongSi> >(json);
                foreach (OrderDetail_FenGongSi odEnt in odEnts)
                {
                    odEnt.Order_FenGongSi_Id = oEnt.Id;
                    odEnt.DoCreate();
                    sql = "select sum(Quantity) from SHHG_AimExamine..OrderDetail_FenGongSi where OrderPart_Id='" + odEnt.OrderPart_Id + "'";
                    OrdersPart opEnt = OrdersPart.Find(odEnt.OrderPart_Id);
                    opEnt.SaleQuan = DataHelper.QueryValue <Int32>(sql);
                    opEnt.DoUpdate();
                }
                break;

            case "loadform":
                if (string.IsNullOrEmpty(id))
                {
                    oEnt        = new Order_FenGongSi();
                    oEnt.Number = DataHelper.QueryValue <string>("select SHHG_AimExamine.dbo.fun_getOrderNumber()");
                    SysUser  suEnt = SysUser.Find(Aim.Portal.Web.WebPortalService.CurrentUserInfo.UserID);
                    Customer cEnt  = Customer.Find(suEnt.LastLogIP);
                    oEnt.FenGongSiId   = cEnt.Id;
                    oEnt.FenGongSiName = cEnt.Name;
                }
                Response.Write("{success: true  ,data:" + JsonHelper.GetJsonString(oEnt) + "}");
                Response.End();
                break;

            case "loaddetail":
                if (!string.IsNullOrEmpty(id))
                {
                    sql = @"select a.Id,a.ProductId,a.OrderPart_Id,a.Name,a.Code,a.PurchasePrice,a.SecondPrice,
                        a.Quantity,a.Amount,a.Remark,(b.Count-isnull(b.SaleQuan,0)+a.Quantity) as MaxQuan
                        from SHHG_AimExamine..Orderdetail_FenGongSi a 
                        left join SHHG_AimExamine..OrdersPart b on a.OrderPart_Id=b.Id where a.Order_FenGongSi_Id='" + id + "'";
                    dt  = DataHelper.QueryDataTable(sql);
                    Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                    Response.End();
                }
                break;

            case "update":
                obj = Request["data"];
                Order_FenGongSi tempEnt = JsonHelper.GetObject <Order_FenGongSi>(obj);
                EasyDictionary  dic     = JsonHelper.GetObject <EasyDictionary>(obj);
                oEnt = DataHelper.MergeData <Order_FenGongSi>(oEnt, tempEnt, dic.Keys);
                oEnt.DoUpdate();
                sql = "delete from SHHG_AimExamine..Orderdetail_FenGongSi where Order_FenGongSi_Id='" + id + "'";
                DataHelper.ExecSql(sql);
                odEnts = JsonHelper.GetObject <IList <OrderDetail_FenGongSi> >(Request["json"]);
                foreach (OrderDetail_FenGongSi odEnt in odEnts)
                {
                    odEnt.Order_FenGongSi_Id = oEnt.Id;
                    odEnt.DoCreate();
                    OrdersPart opEnt = OrdersPart.Find(odEnt.OrderPart_Id);
                    sql            = "select isnull(sum(Quantity),0) from SHHG_AimExamine..Orderdetail_FenGongSi where OrderPart_Id='" + odEnt.OrderPart_Id + "'";
                    opEnt.SaleQuan = DataHelper.QueryValue <Int32>(sql);
                    opEnt.DoUpdate();
                }
                break;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Index = RequestData.Get <string>("Index");
            CC    = RequestData.Get <string>("CC");
            string ids = RequestData.Get <string>("ids");

            switch (RequestActionString)
            {
            case "delete":
                if (!string.IsNullOrEmpty(ids))
                {
                    string[] idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < idArray.Length; i++)
                    {
                        oiEnt = OrderInvoice.Find(idArray[i]);
                        IList <OrderInvoiceDetail> oidEnts = OrderInvoiceDetail.FindAllByProperty("OrderInvoiceId", oiEnt.Id);
                        foreach (OrderInvoiceDetail oidEnt in oidEnts)
                        {
                            OrdersPart opEnt = OrdersPart.Find(oidEnt.OrderDetailId);
                            opEnt.BillingCount = opEnt.BillingCount - oidEnt.InvoiceCount;
                            opEnt.DoUpdate();
                            oidEnt.DoDelete();
                        }
                        //删除发票的时候 回滚销售订单的发票状态   soEnt.InvoiceState = "";
                        string[] oidArray = oiEnt.OId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string oid in oidArray)
                        {
                            SaleOrder soEnt = SaleOrder.Find(oid);
                            sql = "select count(Id) from SHHG_AimExamine..OrdersPart where BillingCount>0 and OId='" + oid + "'";
                            if (DataHelper.QueryValue <int>(sql) == 0)
                            {
                                soEnt.InvoiceState = "";
                            }
                            else
                            {
                                soEnt.InvoiceState = "已部分开发票";
                            }
                            soEnt.DoUpdate();
                        }
                        oiEnt.DoDelete();
                    }
                }
                break;

            case "RollBack":
                if (!string.IsNullOrEmpty(ids))
                {
                    string[] idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < idArray.Length; i++)
                    {
                        oiEnt           = OrderInvoice.Find(idArray[i]);
                        oiEnt.PayState  = null;
                        oiEnt.PayAmount = null;
                        oiEnt.DoUpdate();
                    }
                }
                break;

            case "updateorderinvoicedetail":
                IList <OrderInvoice> oiEnts = OrderInvoice.FindAll();
                foreach (OrderInvoice oiEnt in oiEnts)
                {
                    IList <OrderInvoiceDetail> oidEnts = OrderInvoiceDetail.FindAllByProperty(OrderInvoiceDetail.Prop_OrderInvoiceId, oiEnt.Id);
                    if (oidEnts.Count == 0)
                    {
                        JArray ja = JsonHelper.GetObject <JArray>(oiEnt.Child);
                        foreach (JObject jo in ja)
                        {
                            OrderInvoiceDetail oidEnt = new OrderInvoiceDetail();
                            oidEnt.OrderDetailId  = jo.Value <string>("Id");
                            oidEnt.OrderInvoiceId = oiEnt.Id;
                            oidEnt.SaleOrderId    = jo.Value <string>("OId");
                            oidEnt.ProductId      = jo.Value <string>("ProductId");
                            oidEnt.ProductCode    = jo.Value <string>("ProductCode");
                            oidEnt.ProductName    = jo.Value <string>("ProductName");
                            oidEnt.SalePrice      = jo.Value <decimal>("SalePrice");
                            oidEnt.Unit           = jo.Value <string>("Unit");
                            oidEnt.Amount         = jo.Value <decimal>("Amount");
                            oidEnt.Count          = jo.Value <Int32>("Count");
                            oidEnt.InvoiceCount   = jo.Value <Int32>("Count");
                            oidEnt.DoCreate();
                        }
                    }
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
        /// <summary>
        /// 获取销售单开发票状态,并修改销售详细开票数量
        /// </summary>
        /// <param name="json">开票明细json</param>
        /// <param name="oid">销售单Id</param>
        /// <returns></returns>
        private string getInvoiceState(IList <string> strList, string oid, string onumber)
        {
            OrdersPart[] ops1 = OrdersPart.FindAllByProperty("OId", oid);//查出来的
            Dictionary <string, object> dic = null;

            //dtall 所有需要开发票的 dttemp 当前订单该开票的商品
            //DataTable dttemp = null;
            //DataRow[] rows = dtall.Select("OId='" + oid + "'");
            //dttemp = dtall.Clone();
            //foreach (DataRow row in rows)
            //{
            //    dttemp.Rows.Add(row.ItemArray);
            //}

            for (int i = 0; i < strList.Count; i++)
            {
                dic = FromJson(strList[i]) as Dictionary <string, object>;
                if (dic["Type"] + "" == "销售")
                {
                    foreach (OrdersPart op1 in ops1)
                    {
                        if (op1.Id == dic["Id"] + "")
                        {
                            if (op1.BillingCount == null)
                            {
                                op1.BillingCount = Convert.ToInt32(dic["BcCount"]);
                            }
                            else
                            {
                                op1.BillingCount += Convert.ToInt32(dic["BcCount"]);
                            }
                            op1.DoUpdate();
                            break;
                        }
                    }
                }
                else if (dic["Type"] + "" == "退货")
                {
                    //估计用不到
                }
                else if (dic["Type"] + "" == "换货")
                {
                    ChangeOrderPart[] chanparts = ChangeOrderPart.FindAllByProperty("OId", oid);

                    foreach (ChangeOrderPart chanpart in chanparts)
                    {
                        if (chanpart.Id == dic["Id"] + "")
                        {
                            if (chanpart.BillingCount == null)
                            {
                                chanpart.BillingCount = Convert.ToInt32(dic["BcCount"]);
                            }
                            else
                            {
                                chanpart.BillingCount += Convert.ToInt32(dic["BcCount"]);
                            }
                            chanpart.DoUpdate();
                            break;
                        }
                    }
                }
            }
            //查询 以获得state
            return(DataHelper.QueryValue <string>("select " + db + ".dbo.fun_getWKPCount('" + oid + "')"));
        }
Beispiel #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Aim.Portal.Web.WebPortalService.CheckLogon();
            }
            catch
            {
                Response.Write("<script> window.location.href = '/Login.aspx';</script>");
                Response.End();
            }
            string sql = "";

            string where = "";
            DataTable dt;
            string    action = Request["action"];
            string    id     = Request["id"];

            switch (action)
            {
            case "load":
                string Number = Request["Number"];
                if (!string.IsNullOrEmpty(Number))
                {
                    where += " and number like '%" + Number + "%'";
                }
                if (!string.IsNullOrEmpty(Request["ProductCode"]))
                {
                    where += " and Id in (select distinct OId from SHHG_AimExamine..OrdersPart where PCode like '%" + Request["ProductCode"] + "%')";
                }
                sql = @"select * from SHHG_AimExamine..SaleOrders where    
                          CId  in ('b1b1e57e-1e6e-4d75-a631-089370041d5b','c241fa9e-813d-47cc-9267-2f26330fa957','db2b0081-53dc-41f3-81e7-893c0c6333d8')" + where;
                dt  = DataHelper.QueryDataTable(GetPageSql(sql));
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + ",total:" + totalProperty + "}");
                Response.End();
                break;

            case "loaddetail":
                sql = @"select a.* from SHHG_AimExamine..OrdersPart a  
                          left join SHHG_AimExamine..SaleOrders b on  b.Id=a.OId  where a.OId= '" + id + "'";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{innerrows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "delete":
                IList <OrderDetail_FenGongSi> odEnts = OrderDetail_FenGongSi.FindAllByProperty(OrderDetail_FenGongSi.Prop_Order_FenGongSi_Id, id);
                foreach (OrderDetail_FenGongSi odEnt in odEnts)
                {
                    sql = "select isnull(sum(Quantity),0) from SHHG_AimExamine..OrderDetail_FenGongSi where OrderPart_Id='" + odEnt.OrderPart_Id + "'";
                    OrdersPart opEnt = OrdersPart.Find(odEnt.OrderPart_Id);
                    opEnt.SaleQuan = DataHelper.QueryValue <Int32>(sql);
                    opEnt.DoUpdate();
                    odEnt.Delete();
                }
                Order_FenGongSi oEnt = Order_FenGongSi.Find(id);
                oEnt.DoDelete();
                Response.Write("{success:true}");
                Response.End();
                break;

            case "loadsecond":
                sql = @"select a.*,b.CustomerName,b.CreateTime from SHHG_AimExamine..OrderDetail_FenGongSi a  
                          left join SHHG_AimExamine..Order_FenGongSi b on  b.Id=a.Order_FenGongSi_Id  where a.OrderPart_Id= '" + Request["orderpartid"] + "' order by b.CreateTime asc";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{innerrows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;
            }
        }
        /// <summary>
        /// 更新出库状态
        /// </summary>
        /// <param name="childjson">出库单出库商品json</param>
        private void GetDeliveryState(IList <string> strList, string paids)
        {
            string db = ConfigurationManager.AppSettings["ExamineDB"];
            Dictionary <string, object> dic = null;
            OrdersPart op = null;

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

                if (dic != null)
                {
                    op = OrdersPart.TryFind(dic["PId"]);
                    if (op != null)
                    {
                        op.OutCount = (op.OutCount == null ? 0 : Convert.ToInt32(op.OutCount)) + Convert.ToInt32(dic["OutCount"]);
                        op.DoSave();
                    }
                    else
                    {
                        //throw new Exception("PId未在OrdersPart的Id中");
                    }
                }
            }

            //更新销售单状态
            string[]  oids  = paids.Split(',');
            SaleOrder order = null;
            string    count = "0";//待出库数量
            string    state = "";

            OrdersPart[] ops   = null;
            string       jsons = "";

            foreach (string str in oids)
            {
                if (string.IsNullOrEmpty(str))
                {
                    continue;
                }

                count = DataHelper.QueryValue("select count(1) from " + db + "..OrdersPart where OId='" + str + "' and (OutCount is null or OutCount<>[Count])") + "";
                if (count == "0")
                {
                    //已出库state
                    //state = "已出库";
                    state = "已全部生成出库单";
                }
                else
                {
                    //state = "部分出库";
                    state = "部分生成出库单";
                }
                order = SaleOrder.TryFind(str);
                if (order != null)
                {
                    jsons = "";
                    order.DeliveryState = state;

                    //更新order的json
                    ops = OrdersPart.FindAllByProperty("OId", str);

                    //拼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 += "},";
                    }

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

                    order.DoSave();
                }
            }
        }
Beispiel #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Aim.Portal.Web.WebPortalService.CheckLogon();
            }
            catch
            {
                Response.Write("<script> window.location.href = '/Login.aspx';</script>");
                Response.End();
            }
            string sql = "";

            string where = "";
            DataTable dt;
            string    action = Request["action"];
            string    id     = Request["id"];

            switch (action)
            {
            case "load":
                string Number = Request["Number"];
                if (!string.IsNullOrEmpty(Number))
                {
                    where += " and number like '%" + Number + "%'";
                }
                if (!string.IsNullOrEmpty(Request["ProductCode"]))
                {
                    where += " and Id in (select distinct Order_FenGongSi_Id from SHHG_AimExamine..OrderDetail_FenGongSi where Code like '%" + Request["ProductCode"] + "%')";
                }
                SysUser suEnt = SysUser.Find(Aim.Portal.Web.WebPortalService.CurrentUserInfo.UserID);
                if (!string.IsNullOrEmpty(suEnt.LastLogIP))
                {
                    where += " and FenGongSiId='" + suEnt.LastLogIP + "' ";
                }
                sql = @"select * from SHHG_AimExamine..Order_FenGongSi where 1=1 " + where;
                dt  = DataHelper.QueryDataTable(GetPageSql(sql));
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + ",total:" + totalProperty + "}");
                Response.End();
                break;

            case "loaddetail":
                sql = @"select a.*,c.Number as PurchaseNo from SHHG_AimExamine..OrderDetail_FenGongSi a 
                          left join SHHG_AimExamine..OrdersPart b  on a.OrderPart_Id=b.Id 
                          left join SHHG_AimExamine..SaleOrders c on  c.Id=b.OId  where a.Order_FenGongSi_Id= '" + id + "'";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{innerrows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "delete":
                IList <OrderDetail_FenGongSi> odEnts = OrderDetail_FenGongSi.FindAllByProperty(OrderDetail_FenGongSi.Prop_Order_FenGongSi_Id, id);
                foreach (OrderDetail_FenGongSi odEnt in odEnts)
                {
                    sql = "select isnull(sum(Quantity),0) from SHHG_AimExamine..OrderDetail_FenGongSi where OrderPart_Id='" + odEnt.OrderPart_Id + "'";
                    OrdersPart opEnt = OrdersPart.Find(odEnt.OrderPart_Id);
                    opEnt.SaleQuan = DataHelper.QueryValue <Int32>(sql);
                    opEnt.DoUpdate();
                    odEnt.Delete();
                }
                Order_FenGongSi oEnt = Order_FenGongSi.Find(id);
                oEnt.DoDelete();
                Response.Write("{success:true}");
                Response.End();
                break;
            }
        }