Esempio n. 1
0
 internal int InsertReturn(Inv_Return Inv_ReturnObj)
 {
     try
     {
         _context.Inv_Return.AddObject(Inv_ReturnObj);
         _context.SaveChanges();
         return(1);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 2
0
 internal int InsertReturn(Inv_Return Inv_ReturnObj)
 {
     return(buyCentralDal.InsertReturn(Inv_ReturnObj));
 }
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime date = DateTime.Today;
                GetNewChallanNo(date);
                string OCODE     = ((SessionUser)Session["SessionUser"]).OCode;
                string Edit_User = ((SessionUser)Session["SessionUser"]).UserId.ToString();
                Guid   UserId    = ((SessionUser)Session["SessionUser"]).UserId;

                List <Inv_Return_Temp> ReturnList = new List <Inv_Return_Temp>();
                string challanNo = txtChalanNoReturn.Text.Trim();
                ReturnList = rChallanBll.GetTempReturn(((SessionUser)Session["SessionUser"]).OCode, UserId);

                foreach (Inv_Return_Temp rchallan in ReturnList)
                {
                    if (ddlStoreName.SelectedValue == "CNT")
                    {
                        Inv_BuyCentral buyCentral = _BuyCentral.GetBuyForReturn(rchallan.BarCode, rchallan.Store_Code);

                        if (buyCentral != null)
                        {
                            // Kamruzzaman...........
                            Inv_Return _return = new Inv_Return();
                            _return.ChallanNo          = txtChalanNoReturn.Text;
                            _return.ChallanNo_To       = rchallan.ChallanNo_To;
                            _return.BarCode            = rchallan.BarCode;
                            _return.ProductId          = Convert.ToInt32(rchallan.ProductId);
                            _return.ProductGroup       = rchallan.ProductGroup;
                            _return.ProductName        = rchallan.ProductName;
                            _return.Remarks            = rchallan.Remarks;
                            _return.Brand              = rchallan.Brand;
                            _return.StyleSize          = rchallan.StyleSize;
                            _return.FloorName          = rchallan.FloorName;
                            _return.UnitName           = rchallan.UnitName;
                            _return.ReceiveQuantity    = rchallan.ReceiveQuantity;
                            _return.CPU                = rchallan.CPU;
                            _return.RPU                = rchallan.RPU;
                            _return.ExpireDate         = rchallan.ExpireDate;
                            _return.BalanceQuanity     = rchallan.BalanceQuanity;
                            _return.PurchaseDate       = rchallan.PurchaseDate;
                            _return.EditDate           = rchallan.EditDate;
                            _return.OCode              = rchallan.OCode;
                            _return.Store_Code         = rchallan.Store_Code;
                            _return.SupplierReturnQty  = rchallan.SupplierReturnQty;
                            _return.SupplierCode       = rchallan.SupplierCode;
                            _return.CurrentCompanyCode = rchallan.CurrentCompanyCode;
                            _return.PurchaseDate       = rchallan.PurchaseDate;
                            _return.EditDate           = DateTime.Today;
                            _return.EditUser           = rchallan.EditUser;
                            _return.OldCompanyCode     = rchallan.OldCompanyCode;
                            _return.ReturnDate         = DateTime.Today;
                            _return.ERetQty            = rchallan.ERetQty;
                            _return.OldCompanyName     = rchallan.OldCompanyName;
                            _return.OldCompanyId       = rchallan.OldCompanyId;
                            _return.ReturnType         = "StoreToCentral";
                            _return.EID                = rchallan.EID;
                            _return.DPT_CODE           = rchallan.DPT_CODE;
                            _return.ProgramId          = rchallan.ProgramId;

                            _BuyCentral.InsertReturn(_return);

                            // buy.BalanceQuanity = buy.BalanceQuanity - rchallan.ERetQty;
                            buyCentral.BalanceQuanity = buyCentral.BalanceQuanity + rchallan.ERetQty;
                            //buyCentral.Id = Convert.ToInt16(hidId.Value);
                            // _BuyCentral.Update_Return_DptWise(buy.Id, buy.BarCode, buy.Store_Code, buy.ChallanNo, buy);

                            _BuyCentral.Update_ForReturnBy_CentralToStore(buyCentral.Id, buyCentral.BarCode, buyCentral.Store_Code, buyCentral.ChallanNo, buyCentral);

                            _BuyCentral.DeleteReturn_Temp(rchallan.Id);
                        }

                        else
                        {
                        }
                    }
                    else
                    {
                        Inv_Buy buy = _BuyCentral.GetBuy_DPT_Return(rchallan.BarCode, rchallan.Store_Code, rchallan.ChallanNo_To);

                        if (buy != null)
                        {
                            // Kamruzzaman...........
                            Inv_Return _return = new Inv_Return();
                            _return.ChallanNo          = txtChalanNoReturn.Text;
                            _return.ChallanNo_To       = rchallan.ChallanNo_To;
                            _return.BarCode            = rchallan.BarCode;
                            _return.ProductId          = Convert.ToInt32(rchallan.ProductId);
                            _return.ProductGroup       = rchallan.ProductGroup;
                            _return.ProductName        = rchallan.ProductName;
                            _return.Brand              = rchallan.Brand;
                            _return.StyleSize          = rchallan.StyleSize;
                            _return.FloorName          = rchallan.FloorName;
                            _return.UnitName           = rchallan.UnitName;
                            _return.ReceiveQuantity    = rchallan.ReceiveQuantity;
                            _return.CPU                = rchallan.CPU;
                            _return.Remarks            = rchallan.Remarks;
                            _return.RPU                = rchallan.RPU;
                            _return.ExpireDate         = rchallan.ExpireDate;
                            _return.BalanceQuanity     = rchallan.BalanceQuanity;
                            _return.PurchaseDate       = rchallan.PurchaseDate;
                            _return.EditDate           = rchallan.EditDate;
                            _return.OCode              = rchallan.OCode;
                            _return.Store_Code         = rchallan.Store_Code;
                            _return.SupplierReturnQty  = rchallan.SupplierReturnQty;
                            _return.SupplierCode       = rchallan.SupplierCode;
                            _return.CurrentCompanyCode = rchallan.CurrentCompanyCode;
                            _return.PurchaseDate       = rchallan.PurchaseDate;
                            _return.EditDate           = DateTime.Today;
                            _return.EditUser           = rchallan.EditUser;
                            _return.OldCompanyCode     = rchallan.OldCompanyCode;
                            _return.ReturnDate         = DateTime.Today;
                            _return.ERetQty            = rchallan.ERetQty;
                            _return.OldCompanyName     = rchallan.OldCompanyName;
                            _return.OldCompanyId       = rchallan.OldCompanyId;
                            _return.ReturnType         = "StoreToStore";
                            _return.EID                = rchallan.EID;
                            _return.DPT_CODE           = rchallan.DPT_CODE;
                            _return.ProgramId          = rchallan.ProgramId;

                            _BuyCentral.InsertReturn(_return);

                            // buy.BalanceQuanity = buy.BalanceQuanity - rchallan.ERetQty;
                            buy.BalanceQuanity = buy.BalanceQuanity + rchallan.ERetQty;
                            //buyCentral.Id = Convert.ToInt16(hidId.Value);
                            _BuyCentral.Update_Return_DptWise(buy.Id, buy.BarCode, buy.Store_Code, buy.ChallanNo, buy);

                            // _BuyCentral.Update_ForReturnBy_CentralToStore(buyCentral.Id, buyCentral.BarCode, buyCentral.Store_Code, buyCentral.ChallanNo, buyCentral);

                            _BuyCentral.DeleteReturn_Temp(rchallan.Id);
                        }

                        else
                        {
                        }
                    }
                }

                grdTransfer.DataSource = null;
                grdTransfer.DataBind();
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Item Returned Successfully')", true);
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }