Esempio n. 1
0
        protected void addStock_Submit(object sender, EventArgs e)
        {
            string itemId     = Request.Form["clothesId"];
            string itemAmount = Request.Form["amount"];

            //int itemAmount = Convert.ToInt32(itemAmount);
            System.Diagnostics.Debug.WriteLine(itemId + itemAmount);
            applyResult = DBModel.sharedDBModel().addApplyFromSystem(theStaff.staffId);
            if (applyResult != null)
            {
                if (DBModel.sharedDBModel().addApplyDetailInfoFromSystemWithApplyIdItemIdAndItemAmount(theStaff.staffId, applyResult.applyId, itemId, int.Parse(itemAmount)))
                {
                    System.Diagnostics.Debug.WriteLine("diao huo chenggong ");
                    Response.Redirect("Manager_StockInfo.aspx");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("diaohuo shi bai ");
                    Session["errorMessage"] = "从总店调货失败";
                    Session["returnURL"]    = "Manager_AddStockPage.aspx";
                    Response.Redirect("Error.aspx");
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("diaohuo shi bai ");
                Session["errorMessage"] = "从总店调货失败";
                Session["returnURL"]    = "Manager_AddStockPage.aspx";
                Response.Redirect("Error.aspx");
            }
        }
 protected void addStock_Submit(object sender, EventArgs e)
 {
     string shopId = Request.Form["shopid"];
     string itemId = Request.Form["clothesId"];
     string itemAmount = Request.Form["amount"];
     //int itemAmount = Convert.ToInt32(itemAmount);
     System.Diagnostics.Debug.WriteLine(shopId + itemId + itemAmount);
     applyResult = DBModel.sharedDBModel().addApplyFromOtherShop(theStaff.staffId,shopId);
     if (applyResult != null)
     {
         if (DBModel.sharedDBModel().addApplyDetailInfoFromOtherShopWithApplyIdItemIdAndItemAmount(theStaff.staffId,applyResult.applyId, itemId, int.Parse(itemAmount)))
         {
             System.Diagnostics.Debug.WriteLine("diao huo chenggong ");
             Response.Redirect("Manager_StockInfo.aspx");
         }
         else
         {
             System.Diagnostics.Debug.WriteLine("diaohuo shi bai ");
             Session["errorMessage"] = "从分店调货失败,对方的库存已经不足";
             Session["returnURL"] = "Manager_AddStockPage.aspx";
             Response.Redirect("Error.aspx");
         }
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("diaohuo shi bai ");
         Session["errorMessage"] = "从分店调货失败,对方的库存已经不足";
         Session["returnURL"] = "Manager_AddStockPage.aspx";
         Response.Redirect("Error.aspx");
     }
 }
        /**
         * 34.店长申请从总库补货
         * 参数:店长的Id
         * 返回:新建的补货申请表
         * 备注:申请表的状态默认同意状态(通过测试)
         */
        public apply addApplyFromSystem(string staffId)
        {
            string newId = createNewId("apply");
            string shopId = getShopIdByStaffId(staffId);

            using (YMDBEntities db = new YMDBEntities())
            {
                try
                {
                    apply newApply = new apply
                    {
                        applyId = newId,
                        outShop = "SYSTEM",
                        inShop = shopId,
                        state = "ok",
                        applyTime = DateTime.Now,
                    };
                    db.apply.Add(newApply);
                    db.SaveChanges();
                    return newApply;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("你输错了总库不给你补货,回家去反省.");
                    System.Diagnostics.Debug.WriteLine(ex.StackTrace);
                    return null;
                }                
            }
        }
        /**
         * 36.店长申请从其他店面调货
         * 参数:店长的Id,对方店面的Id
         * 返回:新建的调货申请表
         * 备注:申请表的状态需要设置为申请状态(通过测试)
         */
        public apply addApplyFromOtherShop(string staffId, string otherShopId)
        {
            string shopId = getShopIdByStaffId(staffId);
            if (shopId.Equals(otherShopId))
            {
                System.Diagnostics.Debug.WriteLine("你这玩儿啥呢?自己向自己店申请调货?回去看看参数是不搞错了.");
                return null;
            }
            string newId = createNewId("apply");

            using (YMDBEntities db = new YMDBEntities())
            {
                try
                {
                    apply newApply = new apply
                    {
                        applyId = newId,
                        outShop = otherShopId,
                        inShop = shopId,
                        state = "ok",
                        applyTime = DateTime.Now,
                    };
                    db.apply.Add(newApply);
                    db.SaveChanges();
                    return newApply;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("调货申请不满足外键约束,自己找问题吧.");
                    System.Diagnostics.Debug.WriteLine(ex.StackTrace);
                    return null;
                }
            }
        }