예제 #1
0
        private void DoBatchDelete()
        {
            IList <object> idList = RequestData.GetList <object>("IdList");

            if (idList != null && idList.Count > 0)
            {
                PriceApply.DoBatchDelete(idList.ToArray());
            }
        }
예제 #2
0
 /// <summary>
 /// 查询
 /// </summary>
 private void DoSelect()
 {
     if (!SearchCriterion.Orders.Exists(en => en.PropertyName == "CreateTime"))
     {
         SearchCriterion.Orders.Add(new OrderCriterionItem("CreateTime", false));
     }
     ents = PriceApply.FindAll(SearchCriterion);
     this.PageState.Add("PriceApplyList", ents);
 }
예제 #3
0
        public void StartFlow()
        {
            string     id    = this.RequestData.Get <string>("Id");
            string     state = this.RequestData.Get <string>("state");
            PriceApply pb    = PriceApply.Find(id);

            pb.State = state;
            pb.Save();
            string code = this.RequestData.Get <string>("FlowKey");

            //启动流程
            //表单路径,后面加上参数传入
            string formUrl = "/SaleManagement/FrmPriceApplyView.aspx?op=u&&id=" + id;
            Guid   guid    = Aim.WorkFlow.WorkFlow.StartWorkFlow(id, formUrl, "销售价格申请单(" + pb.Number + ")[" + pb.CreateName + "]", code, this.UserInfo.UserID, this.UserInfo.Name);

            this.PageState.Add("FlowId", guid.ToString());
        }
예제 #4
0
        //创建价格申请单
        private void CreatePriceApply(SaleOrder order)
        {
            PriceApply pa = new PriceApply
            {
                CCode        = order.CCode,
                Child        = order.Child,
                CName        = order.CName,
                CId          = order.CId,
                CreateId     = UserInfo.UserID,
                CreateName   = UserInfo.Name,
                CreateTime   = DateTime.Now,
                ExpectedTime = order.ExpectedTime,
                Number       = order.PANumber,
                OId          = order.Id,
                PreDeposit   = order.PreDeposit.ToString(),
                Reason       = "商品价格低于最低售价"
            };

            pa.DoCreate();
        }
예제 #5
0
        string type = String.Empty; // 对象类型

        #endregion

        #region ASP.NET 事件

        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.Find(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);
                    ent.CCode = Customer.Find(ent.CId).Importance;//2017-08-22客户要求在价格申请单中显示客户等级,客户编号没有什么用,就用次属性代替客户等级
                }

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

            this.PageState.Add("FlowEnum", SysEnumeration.GetEnumDictList("WorkFlow.Simple"));
        }
예제 #6
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"));
        }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string db = ConfigurationManager.AppSettings["ExamineDB"];

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

            SaleOrder ent = null;

            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"));
        }