Beispiel #1
0
        public ActionResult BuyOrderDetail(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("请输入正确的验货单编号")));
            }

            int oId = 0;

            int.TryParse(id, out oId);
            string    uid   = HttpContext.User.Identity.Name;
            BBuyOrder order = null;

            if (oId <= 0)
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("请输入正确的验货单编号")));
            }
            try
            {
                UserManager userMgr    = new UserManager(int.Parse(uid), null);
                BUser       user       = userMgr.CurrentUser;
                BuyManager  buyManager = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
                order = buyManager.GetBuyOrderFullInfo(oId);
            }
            catch (KMJXCException kex)
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode(kex.Message)));
            }
            catch
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("未知错误")));
            }
            return(View(order));
        }
Beispiel #2
0
    void onTouchEvent(string obj)
    {
        if (obj == "Buy_Item")
        {
            if (TouchController.collider.tag != "Utilits")
            {
                if (itemInformation.items.Level <= 4)
                {
                    BuyManager.buyItemLevelUp(itemInformation.items, System.Convert.ToSingle(itemInformation.value.text));

                    if (itemInformation.items.Level >= 4)
                    {
                        Destroy(this.gameObject);

                        TouchController.layerMask = LayerMask.NameToLayer("Default");
                    }

                    this.init();
                }
            }
            else
            {
                BuyManager.buyItemUtilits(itemInformation.items, System.Convert.ToSingle(itemInformation.value.text));
            }
        }
        else if (obj == "Close")
        {
            this.close();

            TouchController.layerMask = LayerMask.NameToLayer("Default");
        }
    }
Beispiel #3
0
        public void ToBuild(int buildId)
        {
            MBuilding mBuilding = BuildingCacher.Instance.GetBuilding(buildId);

            App.Model.Master.MBuilding buildingMaster = mBuilding.Master;
            VBaseMap vBaseMap = (App.Util.SceneManager.CurrentScene as CTop).GetVBaseMap();

            App.Model.MTile[] tiles = vBaseMap.ViewModel.Tiles.Value;
            int currentNum          = System.Array.FindAll(tiles, _ => _.tile_id == buildingMaster.tile_id).Length;

            if (currentNum < buildingMaster.sum)
            {
                if (BuyManager.CanBuy(buildingMaster.price, buildingMaster.price_type))
                {
                    this.StartCoroutine(Build(mBuilding.TileId, vBaseMap, buildingMaster));
                }
                else
                {
                    //Confirm dialog
                }
            }
            else
            {
                //Confirm dialog
                CAlertDialog.Show("已经达到了购买的上限了!");
            }
        }
Beispiel #4
0
        public PQGridData GetBuys()
        {
            PQGridData      data       = new PQGridData();
            HttpContextBase context    = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request    = context.Request;
            string          user_id    = User.Identity.Name;
            UserManager     userMgr    = new UserManager(int.Parse(user_id), null);
            BUser           user       = userMgr.CurrentUser;
            BuyManager      buyManager = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            int             total      = 0;
            int             page       = 1;
            int             pageSize   = 30;

            int.TryParse(request["page"], out page);
            int.TryParse(request["pageSize"], out pageSize);
            if (page <= 0)
            {
                page = 1;
            }

            if (pageSize <= 0)
            {
                pageSize = 30;
            }
            data.data         = buyManager.SearchBuys(null, null, null, null, null, 0, 0, page, pageSize, out total);
            data.totalRecords = total;
            return(data);
        }
Beispiel #5
0
        public PQGridData SearchEnterStock()
        {
            PQGridData      data         = new PQGridData();
            HttpContextBase context      = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request      = context.Request;
            string          user_id      = User.Identity.Name;
            UserManager     userMgr      = new UserManager(int.Parse(user_id), null);
            BUser           user         = userMgr.CurrentUser;
            StockManager    stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            BuyManager      buyManager   = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            int             page         = 1;
            int             pageSize     = 30;
            int             category     = 0;
            int             storeHouse   = 0;


            int.TryParse(request["cid"], out category);
            int.TryParse(request["house"], out storeHouse);
            int.TryParse(request["page"], out page);
            int.TryParse(request["pageSize"], out pageSize);
            string keyword = request["keyword"];
            int    total   = 0;

            data.data         = stockManager.SearchEnterStocks(0, 0, 0, 0, 0, 0, storeHouse, page, pageSize, out total);
            data.curPage      = page;
            data.totalRecords = total;
            return(data);
        }
Beispiel #6
0
        public ApiMessage GetBuyPriceFullInfo()
        {
            ApiMessage message = new ApiMessage()
            {
                Status = "ok"
            };
            HttpContextBase context    = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request    = context.Request;
            string          user_id    = User.Identity.Name;
            UserManager     userMgr    = new UserManager(int.Parse(user_id), null);
            BUser           user       = userMgr.CurrentUser;
            BuyManager      buyManager = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            BBuyPrice       buyPrice   = null;
            int             priceId    = 0;

            try
            {
                int.TryParse(request["buy_price_id"], out priceId);
                if (priceId <= 0)
                {
                    message.Status  = "failed";
                    message.Message = "没有输入询价单编号";
                    return(message);
                }

                buyPrice = buyManager.GetBuyPriceFullInfo(priceId);

                if (buyPrice == null)
                {
                    message.Status  = "failed";
                    message.Message = "询价单编号错误";
                    return(message);
                }

                message.Item = buyPrice;
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbex)
            {
                message.Status  = "failed";
                message.Message = dbex.Message;
            }
            catch (KM.JXC.Common.KMException.KMJXCException kex)
            {
                message.Status  = "failed";
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {
                message.Status  = "failed";
                message.Message = ex.Message;
            }
            finally
            {
            }

            return(message);
        }
Beispiel #7
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #8
0
 void Start()
 {
     locked        = false;
     currentObject = 0;
     if (isLocalPlayer)
     {
         BuildMenu = GameObject.Find("BuildMenu");
         BuyMenu   = GameObject.Find("BuyMenu");
     }
     buyManager = GetComponent <BuyManager>();
     StartCoroutine(LoadDelayer());
 }
Beispiel #9
0
        public ActionResult Homes(BuyModel Buy)
        {
            if (ModelState.IsValid)
            {
                BuyManager obj = new BuyManager();
                int        a   = obj.Homes(Buy);
                return(RedirectToAction("ViewBuy", "Buy"));
            }

            else
            {
                ViewBag.Message = "ChooSe FiLters properLy";
                return(View());
            }
        }
Beispiel #10
0
        public List <BBuyDetail> GetBuyDetails()
        {
            HttpContextBase context    = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request    = context.Request;
            string          user_id    = User.Identity.Name;
            UserManager     userMgr    = new UserManager(int.Parse(user_id), null);
            BUser           user       = userMgr.CurrentUser;
            BuyManager      buyManager = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            int             buy_id     = 0;

            int.TryParse(request["buy_id"], out buy_id);
            List <BBuyDetail> details = buyManager.GetBuyDetails(buy_id);

            return(details);
        }
Beispiel #11
0
        public ActionResult ViewBuy()
        {
            BuyManager      Obj = new BuyManager();
            List <BuyModel> BM  = Obj.SelectBuy();

            if (BM != null)
            {
                return(View(BM));
            }
            else
            {
                ViewBag.message = "Sorry nO results of your Search";
                return(View());
            }
        }
Beispiel #12
0
        public PQGridData GetBuyOrders()
        {
            PQGridData      data       = new PQGridData();
            HttpContextBase context    = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request    = context.Request;
            string          user_id    = User.Identity.Name;
            UserManager     userMgr    = new UserManager(int.Parse(user_id), null);
            BUser           user       = userMgr.CurrentUser;
            BuyManager      buyManager = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            int             total      = 0;
            int             page       = 1;
            int             pageSize   = 30;

            int.TryParse(request["page"], out page);
            int.TryParse(request["pageSize"], out pageSize);
            int order_id    = 0;
            int supplier_id = 0;

            int.TryParse(request["order_id"], out order_id);
            int.TryParse(request["supplier_id"], out supplier_id);
            string keyword = request["keyword"];

            int[] orders = null;
            if (order_id > 0)
            {
                orders = new int[] { order_id };
            }
            int[] suppliers = null;
            if (supplier_id > 0)
            {
                suppliers = new int[] { supplier_id };
            }
            if (page <= 0)
            {
                page = 1;
            }

            if (pageSize <= 0)
            {
                pageSize = 30;
            }
            data.data         = buyManager.SearchBuyOrders(orders, null, suppliers, null, keyword, 0, 0, page, pageSize, out total);
            data.totalRecords = total;
            return(data);
        }
Beispiel #13
0
        public PQGridData GetStoreHouses()
        {
            PQGridData      data         = new PQGridData();
            HttpContextBase context      = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request      = context.Request;
            string          user_id      = User.Identity.Name;
            UserManager     userMgr      = new UserManager(int.Parse(user_id), null);
            BUser           user         = userMgr.CurrentUser;
            StockManager    stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            BuyManager      buyManager   = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);

            List <BStoreHouse> houses = stockManager.GetStoreHouses();

            data.totalRecords = houses.Count;
            data.data         = houses;
            data.curPage      = 1;
            return(data);
        }
Beispiel #14
0
        public PQGridData GetBuyPrices()
        {
            PQGridData      data       = new PQGridData();
            HttpContextBase context    = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request    = context.Request;
            string          user_id    = User.Identity.Name;
            UserManager     userMgr    = new UserManager(int.Parse(user_id), null);
            BUser           user       = userMgr.CurrentUser;
            BuyManager      buyManager = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            string          keyword    = request["keyword"];
            int             total      = 0;
            int             page       = 1;
            int             pageSize   = 30;

            int.TryParse(request["page"], out page);
            int.TryParse(request["pageSize"], out pageSize);
            int price_user_id = 0;
            int supplier_id   = 0;

            int.TryParse(request["user_id"], out price_user_id);
            int.TryParse(request["supplier_id"], out supplier_id);
            int buyPriceId = 0;

            int.TryParse(request["price_id"], out buyPriceId);
            string keyWord = request["keyword"];

            if (page <= 0)
            {
                page = 1;
            }

            if (pageSize <= 0)
            {
                pageSize = 30;
            }

            data.data         = buyManager.SearchBuyPrices(buyPriceId, price_user_id, supplier_id, 0, keyword, page, pageSize, out total);
            data.totalRecords = total;
            data.curPage      = page;
            data.pageSize     = pageSize;
            return(data);
        }
Beispiel #15
0
        protected void ImageButtonComplateOrder_Click(object sender, EventArgs e)
        {
            //var _userName = Session[Sessions.LogedInUserName]?? "Debug Mode";


            buyManager = new BuyManager(basketManager);

            var message = buyManager.ComplateOrder();

            if (message != "")
            {
                Response.Redirect($"~/Error.aspx?error={message}");
            }
            else
            {
                basketManager.ClearBasket();
                RefreshGridView();
                ClearBoardFields();
            }
        }
Beispiel #16
0
        public PQGridData SearchProductWastage()
        {
            PQGridData      data         = new PQGridData();
            HttpContextBase context      = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request      = context.Request;
            string          user_id      = User.Identity.Name;
            UserManager     userMgr      = new UserManager(int.Parse(user_id), null);
            BUser           user         = userMgr.CurrentUser;
            StockManager    stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            BuyManager      buyManager   = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            int             page         = 1;
            int             pageSize     = 30;
            int?            category_id  = null;

            int.TryParse(request["page"], out page);
            int.TryParse(request["pageSize"], out pageSize);
            string keyword = request["keyword"];

            int[]  sids      = null;
            string suppliers = request["suppliers"];

            sids = base.ConvertToIntArrar(suppliers);
            if (request["cid"] != null && request["cid"].ToString() != "" && request["cid"].ToString() != "0")
            {
                int cid = 0;
                int.TryParse(request["cid"], out cid);
                if (cid > 0)
                {
                    category_id = cid;
                }
            }
            int total = 0;

            data.data         = stockManager.SearchProductWastage(sids, keyword, category_id, page, pageSize, out total);
            data.curPage      = page;
            data.totalRecords = total;
            return(data);
        }
Beispiel #17
0
 private void Awake()
 {
     Instance = this;
 }
Beispiel #18
0
 private void OnButtonClicked()
 {
     BuyManager.TryUpgradeAbility(_abilityType);
 }
Beispiel #19
0
        public ApiMessage VerifyOrder()
        {
            ApiMessage      message    = new ApiMessage();
            HttpContextBase context    = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request    = context.Request;
            string          user_id    = User.Identity.Name;
            UserManager     userMgr    = new UserManager(int.Parse(user_id), null);
            BUser           user       = userMgr.CurrentUser;
            BuyManager      buyManager = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);

            try
            {
                int    oid      = 0;
                long   comeDate = 0;
                string odetails = request["order_products"];
                string desc     = request["description"];
                int.TryParse(request["oid"], out oid);

                if (!string.IsNullOrEmpty(request["comedate"]))
                {
                    comeDate = DateTimeUtil.ConvertDateTimeToInt(Convert.ToDateTime(request["comedate"]));
                }

                BBuy buy = new BBuy();
                buy.ID    = 0;
                buy.Order = new BBuyOrder()
                {
                    ID = oid
                };
                buy.ComeDate    = comeDate;
                buy.Description = desc;
                buy.Created     = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                buy.Shop        = new BShop()
                {
                    ID = buyManager.Shop.Shop_ID
                };
                buy.User = new BUser()
                {
                    ID = buyManager.CurrentUser.ID
                };

                if (!string.IsNullOrEmpty(odetails))
                {
                    odetails    = HttpUtility.UrlDecode(odetails);
                    buy.Details = new List <BBuyDetail>();

                    JArray jsons = JArray.Parse(odetails);
                    if (jsons != null && jsons.Count > 0)
                    {
                        for (int i = 0; i < jsons.Count; i++)
                        {
                            JObject jOrder            = (JObject)jsons[i];
                            int     parent_product_id = (int)jOrder["product_id"];
                            JArray  cjorders          = (JArray)jOrder["orders"];

                            if (cjorders != null && cjorders.Count > 0)
                            {
                                for (int j = 0; j < cjorders.Count; j++)
                                {
                                    JObject    json    = (JObject)cjorders[j];
                                    BBuyDetail oDetail = new BBuyDetail();
                                    oDetail.Buy_Order_ID = oid;
                                    double price    = 0;
                                    int    quantity = 0;
                                    double.TryParse(json["price"].ToString(), out price);
                                    int.TryParse(json["quantity"].ToString(), out quantity);
                                    oDetail.Price   = price;
                                    oDetail.Product = new BProduct()
                                    {
                                        ID = (int)json["child_id"]
                                    };
                                    oDetail.Quantity = quantity;

                                    if (quantity <= 0)
                                    {
                                        continue;
                                    }
                                    oDetail.Parent_Product_ID = parent_product_id;
                                    buy.Details.Add(oDetail);
                                }
                            }
                        }
                    }
                }

                bool result = buyManager.VerifyBuyOrder(buy);

                if (result)
                {
                    message.Status = "ok";
                }
                else
                {
                    message.Status  = "failed";
                    message.Message = "验货单创建失败";
                }
            }
            catch (KM.JXC.Common.KMException.KMJXCException kex)
            {
                message.Status  = "failed";
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {
                message.Status  = "failed";
                message.Message = ex.Message;
            }
            finally
            {
            }

            return(message);
        }
Beispiel #20
0
        public ApiMessage UpdateBuyOrder()
        {
            ApiMessage      message    = new ApiMessage();
            HttpContextBase context    = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request    = context.Request;
            string          user_id    = User.Identity.Name;
            UserManager     userMgr    = new UserManager(int.Parse(user_id), null);
            BUser           user       = userMgr.CurrentUser;
            BuyManager      buyManager = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);

            try
            {
                int    oid         = 0;
                long   writedate   = 0;
                long   issuedate   = 0;
                long   enddate     = 0;
                int    supplier_id = 0;
                int    order_user  = 0;
                string odetails    = request["order_products"];
                string desc        = request["description"];
                int.TryParse(request["oid"], out oid);

                if (!string.IsNullOrEmpty(odetails))
                {
                    odetails = HttpUtility.UrlDecode(odetails);
                }

                if (!string.IsNullOrEmpty(request["writedate"]))
                {
                    writedate = DateTimeUtil.ConvertDateTimeToInt(Convert.ToDateTime(request["writedate"]));
                }

                if (!string.IsNullOrEmpty(request["issuedate"]))
                {
                    issuedate = DateTimeUtil.ConvertDateTimeToInt(Convert.ToDateTime(request["issuedate"]));
                }

                if (!string.IsNullOrEmpty(request["enddate"]))
                {
                    enddate = DateTimeUtil.ConvertDateTimeToInt(Convert.ToDateTime(request["enddate"]));
                }

                int.TryParse(request["supplier"], out supplier_id);
                int.TryParse(request["order_user"], out order_user);
                BBuyOrder order = new BBuyOrder();
                order.ID = oid;
                //order.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                //order.Created_By = new BUser() { ID = buyManager.CurrentUser.ID };
                order.Description = desc;
                order.EndTime     = enddate;
                order.InsureTime  = issuedate;
                order.OrderUser   = new BUser()
                {
                    ID = order_user
                };
                order.Shop = new BShop()
                {
                    ID = buyManager.Shop.Shop_ID
                };
                order.Status   = 0;
                order.Supplier = new Supplier()
                {
                    Supplier_ID = supplier_id
                };
                order.WriteTime = writedate;
                if (!string.IsNullOrEmpty(odetails))
                {
                    JArray jOrders = JArray.Parse(odetails);
                    order.Details = new List <BBuyOrderDetail>();
                    if (jOrders != null && jOrders.Count > 0)
                    {
                        for (int i = 0; i < jOrders.Count; i++)
                        {
                            JObject jOrder            = (JObject)jOrders[i];
                            int     parent_product_id = (int)jOrder["product_id"];
                            JArray  cjorders          = (JArray)jOrder["orders"];
                            if (cjorders != null && cjorders.Count > 0)
                            {
                                for (int j = 0; j < cjorders.Count; j++)
                                {
                                    BBuyOrderDetail oDetail = new BBuyOrderDetail();
                                    oDetail.Parent_Product_ID = parent_product_id;
                                    double price    = 0;
                                    int    quantity = 0;
                                    double.TryParse(cjorders[j]["price"].ToString(), out price);
                                    int.TryParse(cjorders[j]["quantity"].ToString(), out quantity);
                                    oDetail.Product = new BProduct()
                                    {
                                        ID = (int)cjorders[j]["child_id"]
                                    };
                                    oDetail.Quantity = quantity;
                                    oDetail.Status   = 0;
                                    oDetail.Price    = price;
                                    if (quantity <= 0)
                                    {
                                        continue;
                                    }
                                    order.Details.Add(oDetail);
                                }
                            }
                        }
                    }
                }

                bool result = buyManager.UpdateBuyOrder(order);
                if (result)
                {
                    message.Status = "ok";
                }
                else
                {
                    message.Status  = "failed";
                    message.Message = "更新失败";
                }
            }
            catch (KM.JXC.Common.KMException.KMJXCException kex)
            {
                message.Status  = "failed";
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {
                message.Status  = "failed";
                message.Message = ex.Message;
            }
            finally
            {
            }

            return(message);
        }
Beispiel #21
0
        public ApiMessage CreateBuyPrice()
        {
            ApiMessage message = new ApiMessage()
            {
                Status = "ok"
            };
            HttpContextBase context    = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request    = context.Request;
            string          user_id    = User.Identity.Name;
            UserManager     userMgr    = new UserManager(int.Parse(user_id), null);
            BUser           user       = userMgr.CurrentUser;
            BuyManager      buyManager = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);

            try
            {
                string details = request["price_details"];
                string desc    = request["desc"];
                string title   = request["title"];
                int    shopId  = 0;
                int.TryParse(request["shop_id"], out shopId);
                if (!string.IsNullOrEmpty(details))
                {
                    details = HttpUtility.UrlDecode(details);
                }

                JArray    jDetails = JArray.Parse(details);
                BBuyPrice buyPrice = new BBuyPrice()
                {
                    Desc = desc, Title = title, Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now)
                };
                buyPrice.Shop = new BShop()
                {
                    ID = buyManager.Shop.Shop_ID
                };
                if (shopId > 0)
                {
                    buyPrice.Shop = new BShop()
                    {
                        ID = shopId
                    };
                }
                buyPrice.Details = new List <BBuyPriceDetail>();
                for (int i = 0; i < jDetails.Count(); i++)
                {
                    JObject         jDetail = (JObject)jDetails[i];
                    BBuyPriceDetail bDetail = new BBuyPriceDetail();
                    bDetail.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                    bDetail.Price   = (double)jDetail["price"];
                    bDetail.Product = new BProduct()
                    {
                        ID = (int)jDetail["sku_id"], ParentID = (int)jDetail["product_id"]
                    };
                    bDetail.Supplier = new BSupplier()
                    {
                        ID = (int)jDetail["supplier_id"]
                    };
                    buyPrice.Details.Add(bDetail);
                }

                bool result = buyManager.CreateBuyPrice(buyPrice);
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbex)
            {
                message.Status  = "failed";
                message.Message = dbex.Message;
            }
            catch (KM.JXC.Common.KMException.KMJXCException kex)
            {
                message.Status  = "failed";
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {
                message.Status  = "failed";
                message.Message = ex.Message;
            }
            finally
            {
            }

            return(message);
        }
Beispiel #22
0
        public PQGridData SearchStocks()
        {
            PQGridData      data         = new PQGridData();
            HttpContextBase context      = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request      = context.Request;
            string          user_id      = User.Identity.Name;
            UserManager     userMgr      = new UserManager(int.Parse(user_id), null);
            BUser           user         = userMgr.CurrentUser;
            StockManager    stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            BuyManager      buyManager   = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            int             page         = 1;
            int             pageSize     = 30;
            int             storeHouse   = 0;
            bool            paging       = false;
            string          product_ids  = request["products"];

            int.TryParse(request["house"], out storeHouse);
            int.TryParse(request["page"], out page);
            int.TryParse(request["pageSize"], out pageSize);
            string     keyword     = request["keyword"];
            int        total       = 0;
            List <int> storeHouses = new List <int>();

            if (storeHouse > 0)
            {
                storeHouses.Add(storeHouse);
            }

            List <int> products = new List <int>();

            if (!string.IsNullOrEmpty(product_ids))
            {
                string[] ids = product_ids.Split(',');
                foreach (string id in ids)
                {
                    products.Add(int.Parse(id));
                }
            }

            if (!string.IsNullOrEmpty(request["paging"]) && request["paging"] == "1")
            {
                paging = true;
            }
            else
            {
                paging = false;
            }
            if (page <= 0)
            {
                page = 1;
            }

            if (pageSize <= 0)
            {
                pageSize = 30;
            }

            data.data         = stockManager.SearchStocks(products, storeHouses, page, pageSize, out total, paging);
            data.curPage      = page;
            data.totalRecords = total;
            return(data);
        }
Beispiel #23
0
        public ApiMessage EnterStockFromBuy()
        {
            HttpContextBase context      = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request      = context.Request;
            string          user_id      = User.Identity.Name;
            UserManager     userMgr      = new UserManager(int.Parse(user_id), null);
            BUser           user         = userMgr.CurrentUser;
            StockManager    stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            BuyManager      buyManager   = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            ApiMessage      message      = new ApiMessage();

            int[] buy_ids     = null;
            int   updateStock = 0;
            int   shouseId    = 0;

            buy_ids = base.ConvertToIntArrar(request["buy_ids"]);
            int.TryParse(request["update_stock"], out updateStock);
            int.TryParse(request["house_id"], out shouseId);
            try
            {
                if (buy_ids != null)
                {
                    foreach (int buy_id in buy_ids)
                    {
                        BEnterStock stock = new BEnterStock();
                        stock.BuyID      = buy_id;
                        stock.Created    = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                        stock.StoreHouse = new BStoreHouse()
                        {
                            ID = shouseId, Shop = new BShop()
                            {
                                ID = stockManager.Shop.Shop_ID
                            }
                        };
                        if (updateStock == 1)
                        {
                            stock.UpdateStock = true;
                        }

                        stockManager.CreateEnterStock(stock);
                    }
                }


                message.Status  = "ok";
                message.Message = "";
            }
            catch (JXC.Common.KMException.KMJXCException kex)
            {
                message.Status  = "failed";
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {
                message.Status  = "failed";
                message.Message = "未知错误";
            }
            finally
            {
            }

            return(message);
        }
Beispiel #24
0
        //保存按钮
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_ProfeCode))
            {
                MessageBox.Show("供应商不可为空,请选择供应商!");
                return;
            }
            BuyManager          bm            = new BuyManager();
            GridItemsCollection grs           = superGridControl1.PrimaryGrid.Rows;
            List <BuyDetail>    buyDetailList = new List <BuyDetail>();
            Buy buy = new Buy();

            if (grs.Count > 1)
            {
                buy.Buy_Code           = BuyOdd;
                buy.Buy_Date           = dateTimePicker1.Value;
                buy.Buy_SupplierCode   = _ProfeCode;
                buy.Buy_SupplierName   = labtextboxTop2.Text.Trim();
                buy.Buy_PurchaseStatus = 1;
                buy.Buy_AuditStatus    = 0;
                buy.Buy_PurchaserID    = "0";
                buy.Buy_SalesMan       = labtextboxBotton1.Text;
                buy.Buy_Operation      = labtextboxBotton3.Text;
                buy.Buy_AuditMan       = "";
                buy.Buy_Remark         = labtextboxBotton2.Text;
                buy.Buy_Clear          = 1;
                buy.Buy_IsPay          = 0;
                buy.Buy_PayMethod      = 0;
                buy.Buy_IsPutSto       = 0;
                buy.Buy_Class          = "采购申请单";
                //buy.Buy_PayMethod =
                //buy.Buy_PayMethod =
                int i = 0;
                foreach (GridRow gr in grs)
                {
                    i++;
                    BuyDetail buyDetail = new BuyDetail();
                    if (gr["gridColumnName"].Value == null)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(gr["gridColumnName"].Value.ToString()))
                    {
                        continue;
                    }
                    if (gr["gridColumnStock"].Value == null || gr["gridColumnStockCode"].Value == null)
                    {
                        MessageBox.Show("货品" +
                                        gr["gridColumnName"].Value.ToString() + "仓库未选择,请选择!");
                        return;
                    }
                    if (gr["gridColumnStock"].Value.ToString() == "" ||
                        gr["gridColumnStockCode"].Value.ToString() == "")
                    {
                        MessageBox.Show("货品" +
                                        gr["gridColumnName"].Value.ToString() + "仓库未选择,请选择!");
                        return;
                    }

                    buyDetail.Buy_LineCode       = BuyOdd + "_" + i.ToString();
                    buyDetail.Buy_StockCode      = gr["gridColumnStockCode"].Value.ToString();
                    buyDetail.Buy_StockName      = gr["gridColumnStock"].Value.ToString();
                    buyDetail.Buy_Code           = BuyOdd;
                    buyDetail.Buy_MaID           = gr["gridColumnMaID"].Value.ToString();
                    buyDetail.Buy_MaName         = gr["gridColumnName"].Value.ToString();
                    buyDetail.Buy_Model          = gr["gridColumnModel"].Value.ToString();
                    buyDetail.Buy_Unit           = gr["gridColumnUnit"].Value.ToString();
                    buyDetail.Buy_CurNumber      = Convert.ToDecimal(gr["gridColumnNumber"].Value);
                    buyDetail.Buy_DiscountAPrice = Convert.ToDecimal(gr["gridColumnPrice"].Value);
                    buyDetail.Buy_Discount       = Convert.ToDecimal(gr["gridColumnDis"].Value);
                    buyDetail.Buy_DiscountBPrice = Convert.ToDecimal(gr["gridColumnDisPrice"].Value);
                    buyDetail.Buy_AmountMoney    = Convert.ToDecimal(gr["gridColumnMoney"].Value);
                    buyDetail.Buy_Clear          = 1;
                    buyDetail.Buy_Remark         = gr["gridColumnRemark"].Value == null ?
                                                   "" : gr["gridColumnRemark"].Value.ToString();

                    buyDetailList.Add(buyDetail);
                }
                try
                {
                    int influence = bm.AddBatch(buy, buyDetailList);
                    if (influence < 1)
                    {
                        MessageBox.Show("未新增任何数据,请检查是否未录入数据,或是存在数据为空");
                    }
                    else
                    {
                        MessageBox.Show("申请采购单成功,该单正在等待审核中.");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("错误代码:3101-创建采购单异常,异常信息:" + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("请先在表格内增加需要采购的商品");
            }
        }
Beispiel #25
0
        public PQGridData SearchBackStock()
        {
            PQGridData      data         = new PQGridData();
            HttpContextBase context      = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request      = context.Request;
            string          user_id      = User.Identity.Name;
            UserManager     userMgr      = new UserManager(int.Parse(user_id), null);
            BUser           user         = userMgr.CurrentUser;
            StockManager    stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            BuyManager      buyManager   = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            int             page         = 1;
            int             pageSize     = 30;
            int             sale_id      = 0;
            int             back_id      = 0;
            int             uid          = 0;
            long            stime        = 0;
            long            etime        = 0;
            int             storeHouseId = 0;

            if (!string.IsNullOrEmpty(request["sdate"]))
            {
                DateTime sdate = DateTime.MinValue;
                DateTime.TryParse(request["sdate"], out sdate);
                if (sdate != DateTime.MinValue)
                {
                    stime = DateTimeUtil.ConvertDateTimeToInt(sdate);
                }
            }
            if (!string.IsNullOrEmpty(request["edate"]))
            {
                DateTime edate = DateTime.MinValue;
                DateTime.TryParse(request["edate"], out edate);
                if (edate != DateTime.MinValue)
                {
                    etime = DateTimeUtil.ConvertDateTimeToInt(edate);
                }
            }
            int.TryParse(request["page"], out page);
            int.TryParse(request["pageSize"], out pageSize);
            int.TryParse(request["sale_id"], out sale_id);
            int.TryParse(request["back_id"], out back_id);
            int.TryParse(request["user_id"], out uid);
            int total = 0;

            int[] backids = null;
            if (back_id > 0)
            {
                backids = new int[] { back_id };
            }
            int[] userids = null;
            if (uid > 0)
            {
                userids = new int[] { uid };
            }
            string[] saleids = null;
            if (sale_id > 0)
            {
                saleids = new string[] { sale_id.ToString() };
            }
            data.data         = stockManager.SearchBackStockDetails(backids, saleids, userids, storeHouseId, stime, etime, page, pageSize, out total);
            data.curPage      = page;
            data.totalRecords = total;
            return(data);
        }