コード例 #1
0
        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();
            }
        }
コード例 #2
0
 private void UpdateSaleOrder()//销售付款创建完毕后  如果该客户有应付款记录   开始执行对应操作
 {
     if (ent.Name == "自动销账")
     {
         sql = @"select * from SHHG_AimExamine..SaleOrders  where InvoiceType='收据' and 
         CId='" + CId + "' and State is null and (PayState is null or PayState='部分付款') order by CreateTime asc";
         IList <EasyDictionary> dics = DataHelper.QueryDictList(sql);
         decimal payamount           = ent.Money.Value;
         ent.CorrespondInvoice = "";
         foreach (EasyDictionary dic in dics)
         {
             if (payamount > 0)
             {
                 SaleOrder oiEnt       = SaleOrder.Find(dic.Get <string>("Id"));
                 decimal   unpayAmount = oiEnt.TotalMoney.Value - (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) -
                                         (oiEnt.DiscountAmount.HasValue ? oiEnt.DiscountAmount.Value : 0) - (oiEnt.ReturnAmount.HasValue ? oiEnt.ReturnAmount.Value : 0);
                 if (payamount >= unpayAmount)
                 {
                     payamount              = payamount - unpayAmount;
                     oiEnt.ReceiptAmount    = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + unpayAmount;
                     oiEnt.PayState         = "已全部付款";
                     ent.CorrespondInvoice += oiEnt.Number + "_" + unpayAmount + ",";
                 }
                 else
                 {
                     oiEnt.ReceiptAmount    = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + payamount;
                     ent.CorrespondInvoice += oiEnt.Number + "_" + payamount + ",";
                     payamount              = 0;
                 }
                 oiEnt.DoUpdate();
             }
         }
         ent.CorrespondState = "已对应";
         ent.DoUpdate();
     }
     if (ent.Name == "手动销账")
     {
         string[] SaleOrderArray = ent.CorrespondInvoice.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
         ent.CorrespondInvoice = "";
         foreach (string str in SaleOrderArray)
         {
             SaleOrder oiEnt       = SaleOrder.FindAllByProperty(SaleOrder.Prop_Number, str).FirstOrDefault <SaleOrder>();
             decimal   unpayAmount = oiEnt.TotalMoney.Value - (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) -
                                     (oiEnt.DiscountAmount.HasValue ? oiEnt.DiscountAmount.Value : 0) - (oiEnt.ReturnAmount.HasValue ? oiEnt.ReturnAmount.Value : 0);
             ent.CorrespondInvoice += oiEnt.Number + "_" + unpayAmount + ",";
             oiEnt.ReceiptAmount    = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + unpayAmount;
             oiEnt.PayState         = "已全部付款";
             oiEnt.DoUpdate();
         }
         ent.CorrespondState = "已对应";
         ent.DoUpdate();
     }
     if (ent.Name == "暂不销账")
     {
         ent.CorrespondInvoice = "";
         ent.DoUpdate();
     }
 }
コード例 #3
0
ファイル: SaleOrderList.aspx.cs プロジェクト: radtek/SHHG_ERP
        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;
            }
        }
コード例 #4
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;
            }
        }
コード例 #5
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;
            }
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string         action = Request["action"];
            string         sql    = "";
            DataTable      dt     = null;
            PaymentInvoice piEnt  = null;
            SaleOrder      soEnt  = null;

            switch (action)
            {
            case "loadpaytype":
                sql = @"select name from SysEnumeration where parentid=(select TOP 1 EnumerationID from SysEnumeration WHERE Code = 'PayType') order by sortindex asc ";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "loadbyorderid":
                soEnt = SaleOrder.Find(Request["orderid"]);
                Response.Write("{data:" + JsonHelper.GetJsonString(soEnt) + "}");
                Response.End();
                break;

            case "create":
                soEnt                   = SaleOrder.Find(Request["orderid"]);
                piEnt                   = JsonHelper.GetObject <PaymentInvoice>(Request["formdata"]);
                piEnt.BillType          = "订单";
                piEnt.CorrespondState   = "已对应";
                piEnt.CollectionType    = "销售收款";
                piEnt.Name              = "手动销账";
                piEnt.CorrespondInvoice = soEnt.Number + "_" + soEnt.TotalMoney;
                piEnt.DoCreate();
                //创建完付款单后,更新订单状态
                soEnt.PayState = "已付款";
                soEnt.DoUpdate();
                break;
            }
        }
コード例 #7
0
ファイル: FrmOrdersEdit.aspx.cs プロジェクト: radtek/SHHG_ERP
        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"));
        }
コード例 #8
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"));
        }
コード例 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string ids = RequestData.Get <string>("ids");

            string[] idArray = null;
            if (!string.IsNullOrEmpty(ids))
            {
                idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            }
            id = RequestData.Get <string>("id");
            if (!string.IsNullOrEmpty(id))
            {
                piEnt = PaymentInvoice.Find(id);
            }
            switch (RequestActionString)
            {
            case "CancelCorrespond":
                foreach (string str in idArray)    //可以同时对多个付款进行撤销对应
                {
                    piEnt = PaymentInvoice.Find(str);
                    string[] invoiceArray = piEnt.CorrespondInvoice.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < invoiceArray.Length; i++)
                    {
                        int       index  = invoiceArray[i].IndexOf("_");
                        string    number = invoiceArray[i].Substring(0, index);  //找到对应的发票号和销账金额 对发票进行回滚
                        decimal   amount = Convert.ToDecimal(invoiceArray[i].Substring(index + 1));
                        SaleOrder oiEnt  = SaleOrder.FindAllByProperty(SaleOrder.Prop_Number, number).FirstOrDefault <SaleOrder>();
                        oiEnt.ReceiptAmount = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) - amount;
                        oiEnt.PayState      = oiEnt.ReceiptAmount > 0 ? "部分付款" : null;
                        oiEnt.DoUpdate();
                    }
                    piEnt.CorrespondInvoice = "";
                    piEnt.CorrespondState   = "";
                    piEnt.Name = "暂不销账";
                    piEnt.DoUpdate();
                }
                break;

            case "AutoCorrespond":
                sql = @"select sum(TotalMoney-isnull(DiscountAmount,0)-isnull(ReturnAmount,0)-isnull(ReceiptAmount,0)) 
                    from SHHG_AimExamine..SaleOrders where  CId='" + piEnt.CId + "' and State is null and InvoiceType='收据' and (PayState is null or PayState='部分付款')";
                decimal TotalArrearage = DataHelper.QueryValue <decimal>(sql);
                if (TotalArrearage >= piEnt.Money)
                {
                    sql = @"select * from SHHG_AimExamine..SaleOrders  where InvoiceType='收据' and 
                          CId='" + piEnt.CId + "' and State is null and (PayState is null or PayState='部分付款') order by CreateTime asc";
                    IList <EasyDictionary> dics = DataHelper.QueryDictList(sql);
                    decimal payamount           = piEnt.Money.Value;
                    piEnt.CorrespondInvoice = "";
                    foreach (EasyDictionary dic in dics)
                    {
                        if (payamount > 0)
                        {
                            SaleOrder oiEnt       = SaleOrder.Find(dic.Get <string>("Id"));
                            decimal   unpayAmount = oiEnt.TotalMoney.Value - (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) -
                                                    (oiEnt.DiscountAmount.HasValue ? oiEnt.DiscountAmount.Value : 0) - (oiEnt.ReturnAmount.HasValue ? oiEnt.ReturnAmount.Value : 0);
                            if (payamount >= unpayAmount)
                            {
                                payamount                = payamount - unpayAmount;
                                oiEnt.ReceiptAmount      = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + unpayAmount;
                                oiEnt.PayState           = "已全部付款";
                                piEnt.CorrespondInvoice += oiEnt.Number + "_" + unpayAmount + ",";
                            }
                            else
                            {
                                oiEnt.ReceiptAmount      = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + payamount;
                                piEnt.CorrespondInvoice += oiEnt.Number + "_" + payamount + ",";
                                payamount = 0;
                            }
                            oiEnt.DoUpdate();
                        }
                    }
                    piEnt.CorrespondState = "已对应";
                    piEnt.Name            = "自动销账";
                    piEnt.DoUpdate();
                    PageState.Add("Result", "T");
                }
                else
                {
                    PageState.Add("Result", "F");
                }
                break;

            case "delete":
                foreach (string str in idArray)
                {
                    piEnt = PaymentInvoice.Find(str);
                    piEnt.DoDelete();
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
コード例 #10
0
        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;
            }
        }