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();
            }
        }
Exemple #2
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();
            }
        }
Exemple #3
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;
            }
        }
        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;
            }
        }
        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;
            }
        }
        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;
            }
        }
Exemple #7
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;
            }
        }