コード例 #1
0
        public ActionResult InventoryTransfer(long?id, int?inventoryType, string type)
        {
            InventoryTransferModel inventoryTransferModel = new InventoryTransferModel();

            if (UserRolePermissionForPage.Add == true || UserRolePermissionForPage.Edit == true || UserRolePermissionForPage.View == true)
            {
                if (id > 0)
                {
                    ViewBag.ActionType = type;
                    long purchaseId = Convert.ToInt64(id);
                    inventoryTransferModel = _inventoryTransferService.GetInventoryTransferById(purchaseId);
                }
                else
                {
                    inventoryTransferModel.Date          = DateTime.UtcNow.AddMinutes(LoginInfo.Timeoffset);
                    inventoryTransferModel.ReferenceNo   = _inventoryTransferService.ReferenceNumber().ToString();
                    inventoryTransferModel.InventoryType = Convert.ToInt32(inventoryType);
                }
                inventoryTransferModel.FromStoreList  = _iDropDownService.GetStoreList();
                inventoryTransferModel.ToStoreList    = _iDropDownService.GetStoreList();
                inventoryTransferModel.EmployeeList   = _iDropDownService.GetEmployeeList();
                inventoryTransferModel.IngredientList = _iDropDownService.GetIngredientList();
                inventoryTransferModel.AssetItemList  = _iDropDownService.GetAssetItemList();
                inventoryTransferModel.FoodMenuList   = _iDropDownService.GetFoodMenuListByFoodmenuType(-1);
                return(View(inventoryTransferModel));
            }
            else
            {
                return(RedirectToAction("NotFound", "Error"));
            }
        }
コード例 #2
0
        private void detail_Format(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["StackId"] == null)
            {
                throw new Exception("Your Session has expired");
            }

            DataRow dr = InventoryTransferModel.GetInventoryTransaction(new Guid(HttpContext.Current.Session["StackId"].ToString()));

            txtLIC.Text             = dr["LIC"].ToString();
            txtLIC2.Text            = dr["LIC2"].ToString();
            txtLICName.Text         = dr["LIC"].ToString();
            txtLIC2Name.Text        = dr["LIC2"].ToString();
            txtPhysicalCount.Text   = dr["PhysicalCount"].ToString();
            txtPhysicalCount2.Text  = dr["PhysicalCountTo"].ToString();
            txtPhysicalWeight.Text  = dr["PhysicalWeight"].ToString();
            txtPhysicalWeight2.Text = dr["PhysicalWeighTo"].ToString();
            txtProductionYear.Text  = dr["ProductionYear"].ToString();
            txtShed.Text            = dr["Shed"].ToString();
            txtShed2.Text           = dr["Shed2"].ToString();
            txtStackNo.Text         = dr["StackNumber"].ToString();
            txtStackNo2.Text        = dr["StackNumber2"].ToString();
            txtSymbol.Text          = dr["Symbol"].ToString();
            txtSystemCount.Text     = dr["SystemCount"].ToString();
            txtSystemCount2.Text    = dr["SystemCountTo"].ToString();
            txtSystemWeight.Text    = dr["SystemWeight"].ToString();
            txtSystemWeight2.Text   = dr["SystemWeighTo"].ToString();
            txtTransferDate.Text    = dr["TransitionDate"].ToString();
            txtWarehouse.Text       = dr["WareHouse"].ToString();
        }
コード例 #3
0
 public void BindLIC()
 {
     ddLIC.DataSource     = InventoryTransferModel.GetLICsForInventoryTransfer(CurrentWarehouse);
     ddLIC.DataTextField  = "Name";
     ddLIC.DataValueField = "ID";
     ddLIC.DataBind();
 }
コード例 #4
0
 public void BindReason()
 {
     ddlReason.DataSource     = InventoryTransferModel.GetInventoryTransferReasons();
     ddlReason.DataTextField  = "Description";
     ddlReason.DataValueField = "ID";
     ddlReason.DataBind();
 }
コード例 #5
0
 public void BindShed()
 {
     ddlShed.DataSource     = InventoryTransferModel.GetShedsForInventoryTransfer(CurrentWarehouse, new Guid(ddLIC.SelectedValue));
     ddlShed.DataTextField  = "ShedNumber";
     ddlShed.DataValueField = "ID";
     ddlShed.DataBind();
 }
コード例 #6
0
        protected void grvInvTransferApproval_SelectedIndexChanged(object sender, EventArgs e)
        {
            Guid ID      = new Guid(((Label)grvInvTransferApproval.SelectedRow.FindControl("lblID")).Text);
            Guid StackID = new Guid(((Label)grvInvTransferApproval.SelectedRow.FindControl("lblStackID")).Text);

            Guid     StackID2        = new Guid(((Label)grvInvTransferApproval.SelectedRow.FindControl("lblStackID2")).Text);
            Guid     LIC2            = new Guid(((Label)grvInvTransferApproval.SelectedRow.FindControl("lblLICID2")).Text);
            int      PhysicalCount   = int.Parse(((Label)grvInvTransferApproval.SelectedRow.FindControl("lblPhysicalCount")).Text);
            int      PhysicalCount2  = int.Parse(((Label)grvInvTransferApproval.SelectedRow.FindControl("lblPhysicalCount2")).Text);
            float    PhysicalWeight  = float.Parse(((Label)grvInvTransferApproval.SelectedRow.FindControl("lblPhysicalWeight")).Text);
            float    PhysicalWeight2 = float.Parse(((Label)grvInvTransferApproval.SelectedRow.FindControl("lblPhysicalWeight2")).Text);
            Guid     ApprovedByID    = UserBLL.CurrentUser.UserId;
            DateTime DateApproved    = DateTime.Now;

            try
            {
                InventoryTransferModel.ApproveInventorysTransfer(ID, ApprovedByID, DateApproved, StackID, StackID2, LIC2,
                                                                 (PhysicalCount + PhysicalCount2), (PhysicalWeight + PhysicalWeight2));

                Messages1.SetMessage("Record approved successfully.", WarehouseApplication.Messages.MessageType.Success);
                BindApprovalGridview();
            }
            catch (Exception ex)
            {
                Messages1.SetMessage(ex.Message, WarehouseApplication.Messages.MessageType.Error);
            }
        }
コード例 #7
0
        public ActionResult View(long?id)
        {
            InventoryTransferModel inventoryTransferModel = new InventoryTransferModel();
            long purchaseId = Convert.ToInt64(id);

            inventoryTransferModel = _inventoryTransferService.GetViewInventoryTransferById(purchaseId);
            return(View(inventoryTransferModel));
        }
コード例 #8
0
        private void detail_Format(object sender, EventArgs e)
        {
            rptSubInvTransferDetail rpt = new rptSubInvTransferDetail();
            DataTable dt = InventoryTransferModel.GetInvTransferDetail((new Guid(HttpContext.Current.Session["ID"].ToString())));

            rpt.DataSource    = dt;
            subReport1.Report = rpt;
        }
コード例 #9
0
        public void BindStackInfo2()
        {
            DataRow dr = InventoryTransferModel.GetStackInfo(new Guid(ddlStackNo2.SelectedValue));

            txtProductionYear2.Text = dr["ProductionYear"].ToString();
            txtSymbol2.Text         = dr["Symbol"].ToString();
            txtSystemCount2.Text    = dr["CurrentBalance"].ToString();
            txtSystemWeight2.Text   = dr["CurrentWeight"].ToString();
        }
コード例 #10
0
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            rptInventoryBalance rpt  = new rptInventoryBalance();
            DataTable           dtbl = InventoryTransferModel.GetInventoryBalance(
                new Guid(ddlWarehouse.SelectedValue), new Guid(ddlShed.SelectedValue), new Guid(ddlLIC.SelectedValue));

            rpt.DataSource    = dtbl;
            WebViewer1.Report = rpt;
        }
コード例 #11
0
 public void BindLIC2()
 {
     ddLIC2.Items.Clear();
     ddLIC2.Items.Add(new ListItem("Select LIC", ""));
     ddLIC2.DataSource     = InventoryTransferModel.GetLICsToAssignInventory(CurrentWarehouse, new Guid(ddLIC.SelectedValue));
     ddLIC2.DataTextField  = "Name";
     ddLIC2.DataValueField = "ID";
     ddLIC2.DataBind();
 }
コード例 #12
0
        public ActionResult InventoryTransfer(InventoryTransferModel inventoryTransferModel)
        {
            inventoryTransferModel.FromStoreList  = _iDropDownService.GetStoreList();
            inventoryTransferModel.ToStoreList    = _iDropDownService.GetStoreList();
            inventoryTransferModel.EmployeeList   = _iDropDownService.GetEmployeeList();
            inventoryTransferModel.IngredientList = _iDropDownService.GetIngredientList();
            inventoryTransferModel.FoodMenuList   = _iDropDownService.GetFoodMenuListByFoodmenuType(-1);
            string purchaseMessage = string.Empty;

            if (!ModelState.IsValid)
            {
                string errorString = this.ValidationInveotryTransfer(inventoryTransferModel);
                if (!string.IsNullOrEmpty(errorString))
                {
                    return(Json(new { error = true, message = errorString, status = 201 }));
                }
            }

            if (inventoryTransferModel.InventoryTransferDetail != null)
            {
                if (inventoryTransferModel.InventoryTransferDetail.Count > 0)
                {
                    if (inventoryTransferModel.Id > 0)
                    {
                        int result = _inventoryTransferService.UpdateInventoryTransfer(inventoryTransferModel);
                        if (result > 0)
                        {
                            purchaseMessage = _locService.GetLocalizedHtmlString("EditSuccss");
                        }
                    }
                    else
                    {
                        //inventoryTransferModel.Date = DateTime.UtcNow.AddMinutes(LoginInfo.Timeoffset);
                        inventoryTransferModel.ReferenceNo = _inventoryTransferService.ReferenceNumber().ToString();
                        int result = _inventoryTransferService.InsertInventoryTransfer(inventoryTransferModel);
                        if (result > 0)
                        {
                            purchaseMessage = _locService.GetLocalizedHtmlString("SaveSuccess") + " Reference No is: " + result.ToString();
                        }
                    }
                }
                else
                {
                    purchaseMessage = _locService.GetLocalizedHtmlString("ValidPurchaseDetails");
                    return(Json(new { error = true, message = purchaseMessage, status = 201 }));
                }
            }
            else
            {
                purchaseMessage = _locService.GetLocalizedHtmlString("ValidPurchaseDetails");
                return(Json(new { error = true, message = purchaseMessage, status = 201 }));
            }
            // return View(purchaseModel);
            return(Json(new { error = false, message = purchaseMessage, status = 200 }));
            //return View();
        }
コード例 #13
0
        public void BindStackNo()
        {
            ddlStackNo.Items.Clear();
            ddlStackNo.Items.Add(new ListItem("Select Stack No", ""));

            ddlStackNo.DataSource     = InventoryTransferModel.GetStackNos(CurrentWarehouse, new Guid(ddlShed.SelectedValue), new Guid(ddLIC.SelectedValue));
            ddlStackNo.DataTextField  = "StackNumber";
            ddlStackNo.DataValueField = "ID";
            ddlStackNo.DataBind();
        }
コード例 #14
0
        public void BindLICTo()
        {
            //ddLIC2.DataSource = StackModel.GetWarehouseLICs(new Guid(Session["CurrentWarehouse"].ToString()));
            ddLIC2.Items.Clear();
            ddLIC2.Items.Add(new ListItem("Select LIC", ""));

            ddLIC2.DataSource = InventoryTransferModel.GetLICsInventoryTransferTo(CurrentWarehouse, ProductionYear, Symbol, new Guid(ddLIC.SelectedValue));

            ddLIC2.DataTextField  = "Name";
            ddLIC2.DataValueField = "ID";
            ddLIC2.DataBind();
        }
コード例 #15
0
        public void BindStackNo2()
        {
            ddlStackNo2.Items.Clear();
            ddlStackNo2.Items.Add(new ListItem("Select Stack No", ""));

            if (ddlShed2.SelectedValue != string.Empty)
            {
                ddlStackNo2.DataSource     = InventoryTransferModel.GetStackNosTo(CurrentWarehouse, new Guid(ddlShed2.SelectedValue), ProductionYear, Symbol);
                ddlStackNo2.DataTextField  = "StackNumber";
                ddlStackNo2.DataValueField = "ID";
                ddlStackNo2.DataBind();
            }
        }
コード例 #16
0
 public ActionResult GetOrderById(long Id)
 {
     if (UserRolePermissionForPage.Add == true || UserRolePermissionForPage.Edit == true || UserRolePermissionForPage.View == true)
     {
         InventoryTransferModel inventoryTransferModel = new InventoryTransferModel();
         inventoryTransferModel = _inventoryTransferService.GetInventoryTransferById(Id);
         return(View(inventoryTransferModel));
     }
     else
     {
         return(RedirectToAction("NotFound", "Error"));
     }
 }
コード例 #17
0
        public void BindStackInfo()
        {
            DataRow dr = InventoryTransferModel.GetStackInfo(new Guid(ddlStackNo.SelectedValue));

            if (dr != null)
            {
                txtProductionYear.Text = dr["ProductionYear"].ToString();
                txtSymbol.Text         = dr["Symbol"].ToString();
                txtSystemCount.Text    = dr["CurrentBalance"].ToString();
                txtSystemWeight.Text   = dr["CurrentWeight"].ToString();
                Symbol         = new Guid(dr["CommodityGradeID"].ToString());
                LICID          = new Guid(dr["LICID"].ToString());
                ProductionYear = int.Parse(dr["ProductionYear"].ToString());
                BindLICTo();
            }
        }
コード例 #18
0
        protected void grvInvTransferApproval_SelectedIndexChanged(object sender, EventArgs e)
        {
            Guid     ID           = new Guid(((Label)grvInvTransferApproval.SelectedRow.FindControl("lblID")).Text);
            Guid     ApprovedByID = UserBLL.CurrentUser.UserId;
            DateTime DateApproved = DateTime.Now;

            try
            {
                InventoryTransferModel.ApproveInvTransferLICResign(ID, ApprovedByID, DateApproved);
                Messages1.SetMessage("Record approved successfully.", WarehouseApplication.Messages.MessageType.Success);
                BindApprovalGridview();
            }
            catch (Exception ex)
            {
                Messages1.SetMessage(ex.Message, WarehouseApplication.Messages.MessageType.Error);
            }
        }
コード例 #19
0
 protected void grvInventoryTransfer_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         InventoryTransferModel.CancelInventoryTransfer(new Guid(grvInventoryTransfers.SelectedDataKey[0].ToString()));
         Messages1.SetMessage("Record cancelled successfully.", WarehouseApplication.Messages.MessageType.Success);
         DateTime test;
         if (DateTime.TryParse(txtTrannsferDateSrch.Text, out test))
         {
             BindInventoryTransfer();
         }
     }
     catch (Exception ex)
     {
         Messages1.SetMessage(ex.Message, WarehouseApplication.Messages.MessageType.Error);
     }
 }
コード例 #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ActiveReport rt = new WarehouseApplication.Reports.rptInvTransferLICResign();

            rt.DataSource = InventoryTransferModel.GetInvTransferLICResign((new Guid(HttpContext.Current.Session["ID"].ToString())));

            rt.Run(false);
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "inline; filename=MyPDF.PDF");

            // Create the PDF export object
            PdfExport pdf = new PdfExport();

            // Create a new memory stream that will hold the pdf output
            System.IO.MemoryStream memStream = new System.IO.MemoryStream();
            // Export the report to PDF:
            pdf.Export(rt.Document, memStream);
            // Write the PDF stream out
            Response.BinaryWrite(memStream.ToArray());
            // Send all buffered content to the client
            Response.End();
        }
コード例 #21
0
        private string ValidationInveotryTransfer(InventoryTransferModel inventoryTransferModel)
        {
            string ErrorString = string.Empty;

            if (string.IsNullOrEmpty(inventoryTransferModel.FromStoreId.ToString()) || inventoryTransferModel.FromStoreId == 0)
            {
                ErrorString = _locService.GetLocalizedHtmlString("ValidFormStore");
                return(ErrorString);
            }
            if (string.IsNullOrEmpty(inventoryTransferModel.ToStoreId.ToString()) || inventoryTransferModel.ToStoreId == 0)
            {
                ErrorString = _locService.GetLocalizedHtmlString("ValidToStore");
                return(ErrorString);
            }

            if (inventoryTransferModel.InventoryTransferDetail == null || inventoryTransferModel.InventoryTransferDetail.Count < 1)
            {
                ErrorString = _locService.GetLocalizedHtmlString("ValidTransferDetails");
                return(ErrorString);
            }

            return(ErrorString);
        }
コード例 #22
0
 public int UpdateInventoryTransfer(InventoryTransferModel inventoryTransferModel)
 {
     return(_inventoryTransferRepository.UpdateInventoryTransfer(inventoryTransferModel));
 }
コード例 #23
0
 public void BindApprovalGridview()
 {
     grvInvTransferApproval.DataSource = InventoryTransferModel.GetInvTransferForApprovalLICResign(new Guid(Session["CurrentWarehouse"].ToString()));
     grvInvTransferApproval.DataBind();
 }
コード例 #24
0
        protected void btnTransfer_Click(object sender, EventArgs e)
        {
            countError = 0;
            Guid   ID = Guid.NewGuid();
            string phyCount;
            string phyWeight;
            string InventoryTransferXML;
            string TransferDetailXML = "<InventoryTransfer>";

            if (IsValidTransfer())
            {
                foreach (GridViewRow gvr in this.grvInvTransferLICResign.Rows)
                {
                    phyCount  = ((TextBox)grvInvTransferLICResign.Rows[gvr.RowIndex].Cells[0].FindControl("txtPhysicalCount")).Text;
                    phyWeight = ((TextBox)grvInvTransferLICResign.Rows[gvr.RowIndex].Cells[0].FindControl("txtPhysicalWeight")).Text;

                    if (isValidTransferDetail(phyCount, phyWeight))
                    {
                        TransferDetailXML +=
                            "<InventoryTransferItem>" +
                            "<ID>" + Guid.NewGuid() + "</ID>" +
                            "<TransferID>" + ID + "</TransferID>" +
                            "<ShedID>" + ((Label)grvInvTransferLICResign.Rows[gvr.RowIndex].Cells[0].FindControl("lblShedID")).Text + "</ShedID>" +
                            "<StackNo>" + ((Label)grvInvTransferLICResign.Rows[gvr.RowIndex].Cells[0].FindControl("lblID")).Text + "</StackNo>" +
                            "<PhysicalCount>" + ((TextBox)grvInvTransferLICResign.Rows[gvr.RowIndex].Cells[0].FindControl("txtPhysicalCount")).Text + "</PhysicalCount>" +
                            "<SystemCount>" + ((Label)grvInvTransferLICResign.Rows[gvr.RowIndex].Cells[0].FindControl("lblSystemCount")).Text + "</SystemCount>" +
                            "<PhysicalWeight>" + ((TextBox)grvInvTransferLICResign.Rows[gvr.RowIndex].Cells[0].FindControl("txtPhysicalWeight")).Text + "</PhysicalWeight>" +
                            "<SystemWeight>" + ((Label)grvInvTransferLICResign.Rows[gvr.RowIndex].Cells[0].FindControl("lblSystemWeigh")).Text + "</SystemWeight>" +
                            "</InventoryTransferItem>";
                    }
                }
                TransferDetailXML += "</InventoryTransfer>";

                if (countError == 0)
                {
                    InventoryTransferXML = "<InventoryTransfer>" +
                                           "<ID>" + ID + "</ID>" +
                                           "<WarehouseID>" + new Guid(Session["CurrentWarehouse"].ToString()) + "</WarehouseID>" +
                                           "<LICID>" + ddLIC.SelectedValue + "</LICID>" +
                                           "<LICIDTo>" + ddLIC2.SelectedValue + "</LICIDTo>" +
                                           "<TransitionDate>" + txtTransferDate.Text + "</TransitionDate>" +
                                           "<CreatedBy>" + UserBLL.CurrentUser.UserId + "</CreatedBy>" +
                                           "<CreatedTimestamp>" + DateTime.Now + "</CreatedTimestamp>" +
                                           "<Status>" + 1 + "</Status>" +
                                           "</InventoryTransfer>";
                    try
                    {
                        InventoryTransferModel.InventoryTransferLICResign(InventoryTransferXML, TransferDetailXML);
                        Messages1.SetMessage("Record added successfully.", WarehouseApplication.Messages.MessageType.Success);
                        BindGridviewInvTransfer();

                        if (ID != null)
                        {
                            Session["ID"] = ID;
                            ScriptManager.RegisterStartupScript(this,
                                                                this.GetType(),
                                                                "ShowReport",
                                                                "<script type=\"text/javascript\">" +
                                                                string.Format("javascript:window.open(\"ReportInvTransfer.aspx?id={0}\", \"_blank\",\"height=400px,width=600px,top=0,left=0,resizable=yes,scrollbars=yes\");", Guid.NewGuid()) +
                                                                "</script>",
                                                                false);
                        }
                    }
                    catch (Exception ex)
                    {
                        Messages1.SetMessage(ex.Message, WarehouseApplication.Messages.MessageType.Error);
                    }
                }
            }
        }
コード例 #25
0
 public void BindGridviewInvTransfer()
 {
     dtbl = InventoryTransferModel.GetInventoryTransferByLIC(CurrentWarehouse, new Guid(ddLIC.SelectedValue));
     grvInvTransferLICResign.DataSource = dtbl;
     grvInvTransferLICResign.DataBind();
 }
コード例 #26
0
 void BindInventoryTransfer()
 {
     grvInventoryTransfers.DataSource = InventoryTransferModel.GetInventoryTransferForEdit(new Guid(Session["CurrentWarehouse"].ToString()), DateTime.Parse(txtTrannsferDateSrch.Text));
     grvInventoryTransfers.DataBind();
 }
コード例 #27
0
 public int InsertInventoryTransfer(InventoryTransferModel inventoryTransferModel)
 {
     return(_inventoryTransferRepository.InsertInventoryTransfer(inventoryTransferModel));
 }
コード例 #28
0
        public int InsertInventoryTransfer(InventoryTransferModel inventoryTransferModel)
        {
            int    result = 0;
            int    detailResult = 0;
            string foodMenuId = "NULL", ingredientId = "NULL", assetItemId = "NULL";

            using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString))
            {
                con.Open();
                SqlTransaction sqltrans = con.BeginTransaction();
                var            query    = "INSERT INTO [InventoryTransfer] " +
                                          "  ( FromStoreId, ToStoreId,ReferenceNumber,InventoryType,EntryDate ,EmployeeId,Notes,UserIdInserted,DateInserted,IsDeleted  ) " +
                                          "   VALUES           " +
                                          "  ( @FromStoreId, @ToStoreId,@ReferenceNo,@InventoryType,@Date ,@EmployeeId,@Notes," + LoginInfo.Userid + ",GetUTCDate(),0); " +
                                          "   SELECT CAST(Scope_Identity()  as int); ";
                result = con.ExecuteScalar <int>(query, inventoryTransferModel, sqltrans, 0, System.Data.CommandType.Text);

                if (result > 0)
                {
                    foreach (var item in inventoryTransferModel.InventoryTransferDetail)
                    {
                        /*
                         * int consumptionId = 0;
                         * if (item.ConsumpationStatus.Value.ToString() == "StockIN")
                         * {
                         *  consumptionId = 1;
                         * }
                         * else
                         * {
                         *  consumptionId = 2;
                         * }
                         */
                        if (item.IngredientId == 0)
                        {
                            ingredientId = "NULL";
                        }
                        else
                        {
                            ingredientId = item.IngredientId.ToString();
                        }

                        if (item.AssetItemId == 0)
                        {
                            assetItemId = "NULL";
                        }
                        else
                        {
                            assetItemId = item.AssetItemId.ToString();
                        }

                        if (item.FoodMenuId == 0)
                        {
                            foodMenuId = "NULL";
                        }
                        else
                        {
                            foodMenuId = item.FoodMenuId.ToString();
                        }

                        var queryDetails = "INSERT INTO InventoryTransferDetail" +
                                           " (InventoryTransferId,IngredientId,FoodMenuId,AssetItemId,Qty,ConsumptionStatus,CurrentStock,UserIdInserted,DateInserted,IsDeleted) " +
                                           "VALUES           " +
                                           "(" + result + "," +
                                           "" + ingredientId + "," +
                                           "" + foodMenuId + "," +
                                           "" + assetItemId + "," +
                                           "" + item.Quantity + "," +
                                           "" + 1 + "," +
                                           "" + item.CurrentStock + "," +
                                           "" + LoginInfo.Userid + ",GetUtcDate(),0); " +
                                           " SELECT CAST(ReferenceNumber as INT) from [InventoryTransfer] where id = " + result + "; ";
                        detailResult = con.ExecuteScalar <int>(queryDetails, null, sqltrans, 0, System.Data.CommandType.Text);
                    }
                    if (detailResult > 0)
                    {
                        sqltrans.Commit();

                        CommonRepository commonRepository = new CommonRepository(_ConnectionString);
                        string           sResult          = commonRepository.InventoryPush("IT", result);
                    }
                    else
                    {
                        sqltrans.Rollback();
                    }
                }
                else
                {
                    sqltrans.Rollback();
                }
            }
            return(detailResult);
        }
コード例 #29
0
        public int UpdateInventoryTransfer(InventoryTransferModel inventoryTransferModel)
        {
            int    result = 0;
            string foodMenuId = "NULL", ingredientId = "NULL", assetItemId = "NULL";

            using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString))
            {
                con.Open();
                SqlTransaction sqltrans = con.BeginTransaction();
                var            query    = "Update  InventoryTransfer SET FromStoreId=@FromStoreId,EntryDate=@Date,ToStoreId=@ToStoreId, ReferenceNumber=@ReferenceNo,EmployeeId=@EmployeeId, Notes=@Notes " +
                                          ",[UserIdUpdated] = " + LoginInfo.Userid + " ,[DateUpdated]  = GetUtcDate()  where id= " + inventoryTransferModel.Id + ";";
                result = con.Execute(query, inventoryTransferModel, sqltrans, 0, System.Data.CommandType.Text);

                if (result > 0)
                {
                    int detailResult = 0;
                    if (inventoryTransferModel.DeletedId != null)
                    {
                        foreach (var item in inventoryTransferModel.DeletedId)
                        {
                            var deleteQuery = $"update InventoryTransferDetail set IsDeleted = 1,  UserIdDeleted = " + LoginInfo.Userid + ", DateDeleted = GetutcDate() where id = " + item + ";";
                            result = con.Execute(deleteQuery, null, sqltrans, 0, System.Data.CommandType.Text);
                        }
                    }
                    foreach (var item in inventoryTransferModel.InventoryTransferDetail)
                    {
                        var queryDetails = string.Empty;

                        /*
                         * int consumptionId = 0;
                         * if (item.ConsumpationStatus.Value.ToString() == "StockIN")
                         * {
                         *  consumptionId = 1;
                         * }
                         * else
                         * {
                         *  consumptionId = 2;
                         * }
                         */
                        if (item.IngredientId == 0)
                        {
                            ingredientId = "NULL";
                        }
                        else
                        {
                            ingredientId = item.IngredientId.ToString();
                        }

                        if (item.AssetItemId == 0)
                        {
                            assetItemId = "NULL";
                        }
                        else
                        {
                            assetItemId = item.AssetItemId.ToString();
                        }

                        if (item.FoodMenuId == 0)
                        {
                            foodMenuId = "NULL";
                        }
                        else
                        {
                            foodMenuId = item.FoodMenuId.ToString();
                        }

                        if (item.InventoryTransferId > 0)
                        {
                            queryDetails = "Update InventoryTransferDetail SET " +
                                           " IngredientId = " + ingredientId +
                                           " ,FoodMenuId = " + foodMenuId +
                                           " ,AssetItemId = " + assetItemId +
                                           " ,Qty = " + item.Quantity +
                                           " ,ConsumptionStatus = " + 1 +
                                           " ,CurrentStock = " + item.CurrentStock +
                                           " ,UserIdUpdated = " + LoginInfo.Userid +
                                           " ,DateUpdated = GetUTCDate()" +
                                           " ,IsDeleted = 0" +
                                           " where id = " + item.InventoryTransferId + ";";
                        }
                        else
                        {
                            queryDetails = "INSERT INTO InventoryTransferDetail" +
                                           " (InventoryTransferId, IngredientId,FoodMenuId,AssetItemId,Qty,ConsumptionStatus,CurrentStock,UserIdUpdated,DateInserted,IsDeleted)   " +
                                           "VALUES           " +
                                           "(" + inventoryTransferModel.Id + "," +
                                           "" + ingredientId + "," +
                                           "" + foodMenuId + "," +
                                           "" + assetItemId + "," +
                                           "" + item.Quantity + "," +
                                           "" + 1 + "," +
                                           "" + item.CurrentStock + "," +
                                           "" + LoginInfo.Userid + ",GetUTCDate(),0)";
                        }
                        detailResult = con.Execute(queryDetails, null, sqltrans, 0, System.Data.CommandType.Text);
                    }

                    if (detailResult > 0)
                    {
                        sqltrans.Commit();
                    }
                    else
                    {
                        sqltrans.Rollback();
                    }
                }
                else
                {
                    sqltrans.Rollback();
                }
            }

            return(result);
        }