Пример #1
0
        public void Mapper_ToStockContract_ReturnsStockResponse()
        {
            // Arrange
            string currentTime = System.DateTime.Now.ToString();
            var    item        = new StockDB();

            item.Name        = "SendStockTest";
            item.Price       = 123.45f;
            item.LastUpdated = currentTime;

            var mapper = new Mapper();

            StockResponse expectedResponse = new StockResponse
            {
                Name        = "SendStockTest",
                Price       = 123.45f,
                LastUpdated = currentTime
            };

            StockResponse result;

            // Act
            result = mapper.ToStockContract(item);

            // Assert
            Assert.AreEqual(expectedResponse.Name, result.Name);
            Assert.AreEqual(expectedResponse.Price, result.Price);
            Assert.AreEqual(expectedResponse.LastUpdated, result.LastUpdated);
        }
Пример #2
0
        private void showStockOrderedItemDetails(string itemid, string modno, double ordQuant)
        {
            List <stock> stockList = new List <stock>();

            stockList = StockDB.getStockDetailForStockIssue(itemid, modno, ordQuant);
            showStockListOrderedInGridView(stockList);
        }
Пример #3
0
    protected void GrdRegistration_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Label lblId = (Label)GrdRegistration.Rows[e.RowIndex].FindControl("lblId");

        try
        {
            Stock stock = StockDB.GetByID(Convert.ToInt32(lblId.Text));
            if (stock != null)
            {
                StockDB.Delete(Convert.ToInt32(lblId.Text));
                StockUpdateHistoryDB.Insert(stock.Organisation.OrganisationID, stock.Offering.OfferingID, -1 * stock.Quantity, false, true, Convert.ToInt32(Session["StaffID"]));
            }
        }
        catch (ForeignKeyConstraintException fkcEx)
        {
            if (Utilities.IsDev())
            {
                HideTableAndSetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message);
            }
            else
            {
                HideTableAndSetErrorMessage("Can not delete because other records depend on this");
            }
        }

        FillGrid();
        FillGridUpdateHistory();
    }
Пример #4
0
    protected void GrdRegistration_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label        lblId                = (Label)GrdRegistration.Rows[e.RowIndex].FindControl("lblId");
        DropDownList ddlOffering          = (DropDownList)GrdRegistration.Rows[e.RowIndex].FindControl("ddlOffering");
        DropDownList ddlWarningAmount     = (DropDownList)GrdRegistration.Rows[e.RowIndex].FindControl("ddlWarningAmount");
        DropDownList ddlQuantity_Zeros    = (DropDownList)GrdRegistration.Rows[e.RowIndex].FindControl("ddlQuantity_Zeros");
        DropDownList ddlQuantity_Tens     = (DropDownList)GrdRegistration.Rows[e.RowIndex].FindControl("ddlQuantity_Tens");
        DropDownList ddlQuantity_Hundreds = (DropDownList)GrdRegistration.Rows[e.RowIndex].FindControl("ddlQuantity_Hundreds");


        Stock stock = StockDB.GetByID(Convert.ToInt32(lblId.Text));

        if (stock != null)
        {
            int qty = 100 * Convert.ToInt32(ddlQuantity_Hundreds.SelectedValue) + 10 * Convert.ToInt32(ddlQuantity_Tens.SelectedValue) + Convert.ToInt32(ddlQuantity_Zeros.SelectedValue);
            StockDB.Update(stock.StockID, stock.Organisation.OrganisationID, stock.Offering.OfferingID, qty, Convert.ToInt32(ddlWarningAmount.SelectedValue));
            if (qty != stock.Quantity)
            {
                StockUpdateHistoryDB.Insert(stock.Organisation.OrganisationID, stock.Offering.OfferingID, qty - stock.Quantity, false, false, Convert.ToInt32(Session["StaffID"]));
            }
        }

        GrdRegistration.EditIndex = -1;
        FillGrid();
        FillGridUpdateHistory();
    }
Пример #5
0
        public void Mapper_ToStockDBModelOverride_ReturnsStockDB()
        {
            // Arrange
            string currentTime = System.DateTime.Now.ToString();

            StockDB stockDB = new StockDB
            {
                Name        = "StockDBName",
                Price       = 111.22f,
                LastUpdated = currentTime
            };

            StockRequest stockRequest = new StockRequest
            {
                Name  = "StockRequestName",
                Price = 222.33f
            };

            var expectedStockDB = new StockDB();

            expectedStockDB.Name        = "StockDBName";
            expectedStockDB.Price       = 222.33f;
            expectedStockDB.LastUpdated = currentTime;

            var mapper = new Mapper();

            StockDB result;

            // Act
            result = mapper.ToStockDBModel(stockDB, stockRequest);

            // Assert
            Assert.AreEqual(expectedStockDB.Name, result.Name);
            Assert.AreEqual(expectedStockDB.Price, result.Price);
        }
Пример #6
0
        public void Mapper_ToStockDBModel_ReturnsStockDB()
        {
            // Arrange

            StockRequest stockDB = new StockRequest
            {
                Name  = "SendStockTest",
                Price = 123.45f
            };

            var expectedStockDB = new StockDB();

            expectedStockDB.Name        = "SendStockTest";
            expectedStockDB.Price       = 123.45f;
            expectedStockDB.LastUpdated = System.DateTime.Now.ToString();

            var mapper = new Mapper();

            StockDB result;

            // Act
            result = mapper.ToStockDBModel(stockDB);

            // Assert
            Assert.AreEqual(expectedStockDB.Name, result.Name);
            Assert.AreEqual(expectedStockDB.Price, result.Price);
        }
Пример #7
0
        private static byte[] Serialize(StockDB stockDB)
        {
            // serialize the object to send to rabbitMQ
            var jsonified = JsonConvert.SerializeObject(stockDB);

            return(Encoding.ASCII.GetBytes(jsonified));
        }
Пример #8
0
 public StockDB ToStockDBModel(StockDB stockDB, StockRequest stockRequest)
 {
     return(new StockDB
     {
         Name = stockDB.Name,
         Price = stockRequest.Price,
         LastUpdated = DateTime.UtcNow.ToString()
     });
 }
Пример #9
0
 public StockResponse ToStockContract(StockDB stockDB)
 {
     return(new StockResponse
     {
         Name = stockDB.Name,
         Price = stockDB.Price,
         LastUpdated = stockDB.LastUpdated
     });
 }
Пример #10
0
 private void ListQtyDetails()
 {
     try
     {
         pnlList.Visible = true;
         grdList.Visible = true;
         grdList.Rows.Clear();
         ReportPOvsInvoiceQtyDB      sdb     = new ReportPOvsInvoiceQtyDB();
         List <reportpovsinvoiceqty> qtylist = ReportPOvsInvoiceQtyDB.QtyList();
         List <TotalStock>           tStock  = StockDB.TotalStock(Main.MainStore);
         foreach (reportpovsinvoiceqty poqty in qtylist)
         {
             if (poqty.BalanceQty > 0)
             {
                 try
                 {
                     grdList.Rows.Add();
                     grdList.Rows[grdList.RowCount - 1].Cells["StockItemID"].Value   = poqty.StockItemID;
                     grdList.Rows[grdList.RowCount - 1].Cells["StockItemName"].Value = poqty.StockItemName;
                     grdList.Rows[grdList.RowCount - 1].Cells["POQty"].Value         = poqty.POQty;
                     grdList.Rows[grdList.RowCount - 1].Cells["BilledQty"].Value     = poqty.BilledQty;
                     grdList.Rows[grdList.RowCount - 1].Cells["BalanceQty"].Value    = poqty.BalanceQty;
                     try
                     {
                         TotalStock tstk = tStock.Single(s => s.StockItemID == poqty.StockItemID);
                         if (tstk != null)
                         {
                             grdList.Rows[grdList.RowCount - 1].Cells["PresentStock"].Value = tstk.Stock;
                         }
                         if (poqty.BalanceQty <= tstk.Stock)
                         {
                             grdList.Rows[grdList.RowCount - 1].Cells["PresentStock"].Style.BackColor = Color.Yellow;
                         }
                     }
                     catch (Exception ex)
                     {
                         grdList.Rows[grdList.RowCount - 1].Cells["PresentStock"].Value = 0;
                     }
                 }
                 catch (Exception ex)
                 {
                 }
             }
         }
         if (grdList.RowCount > 0)
         {
             txtSearch.Visible        = true;
             lblSearch.Visible        = true;
             btnExportToExcel.Visible = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in Stock listing");
     }
 }
Пример #11
0
    protected void FillGrid()
    {
        Organisation org = null;

        if (IsValidFormID())
        {
            org = OrganisationDB.GetByID(GetFormID());
        }


        DataTable dt = org == null ? dt = StockDB.GetDataTable(!UserView.GetInstance().IsAgedCareView ? 5 : 6) : dt = StockDB.GetDataTable_ByOrg(org.OrganisationID);

        Session["registerstocktoorg_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["registerstocktoorg_sortexpression"] != null && Session["registerstocktoorg_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort = Session["registerstocktoorg_sortexpression"].ToString();
                GrdRegistration.DataSource = dataView;
            }
            else
            {
                GrdRegistration.DataSource = dt;
            }


            try
            {
                GrdRegistration.DataBind();
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdRegistration.DataSource = dt;
            GrdRegistration.DataBind();

            int TotalColumns = GrdRegistration.Rows[0].Cells.Count;
            GrdRegistration.Rows[0].Cells.Clear();
            GrdRegistration.Rows[0].Cells.Add(new TableCell());
            GrdRegistration.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdRegistration.Rows[0].Cells[0].Text       = "No Record Found";
        }

        if (org == null || hideFotter)
        {
            GrdRegistration.FooterRow.Visible = false;
        }
    }
Пример #12
0
        private void ListFilteredStock(int opt, string locID)
        {
            try
            {
                grdList.Rows.Clear();
                StockDB      sdb       = new StockDB();
                List <stock> stockList = StockDB.getStockDetailForReport(opt, locID);
                double       total     = 0;
                foreach (stock st in stockList)
                {
                    grdList.Rows.Add();
                    grdList.Rows[grdList.RowCount - 1].Cells["StockItemID"].Value   = st.StockItemID;
                    grdList.Rows[grdList.RowCount - 1].Cells["StockItemName"].Value = st.StockItemName;
                    grdList.Rows[grdList.RowCount - 1].Cells["ModelNo"].Value       = st.ModelNo;
                    grdList.Rows[grdList.RowCount - 1].Cells["ModelName"].Value     = st.ModelName;
                    grdList.Rows[grdList.RowCount - 1].Cells["Unit"].Value          = st.StockItemUnit;
                    grdList.Rows[grdList.RowCount - 1].Cells["InwardDocID"].Value   = st.InwardDocumentID;
                    grdList.Rows[grdList.RowCount - 1].Cells["InwardDocNo"].Value   = st.InwardDocumentNo;
                    grdList.Rows[grdList.RowCount - 1].Cells["InwardDocDate"].Value = st.InwardDocumentDate;
                    grdList.Rows[grdList.RowCount - 1].Cells["StoreLocation"].Value = st.SupplierName; // For Store LOCation name
                    grdList.Rows[grdList.RowCount - 1].Cells["Quantity"].Value      = st.InwardQuantity;
                    grdList.Rows[grdList.RowCount - 1].Cells["PresentStock"].Value  = st.PresentStock;
                    grdList.Rows[grdList.RowCount - 1].Cells["StockOnHold"].Value   = st.StockOnHold;
                    grdList.Rows[grdList.RowCount - 1].Cells["PurchasePrice"].Value = st.PurchasePrice;
                    grdList.Rows[grdList.RowCount - 1].Cells["Value"].Value         = st.PresentStock * st.PurchasePrice;

                    grdList.Rows[grdList.RowCount - 1].Cells["G1Code"].Value = st.Level1GCode;
                    grdList.Rows[grdList.RowCount - 1].Cells["G2Code"].Value = st.Level2GCode;
                    grdList.Rows[grdList.RowCount - 1].Cells["G3Code"].Value = st.Level3GCode;
                    grdList.Rows[grdList.RowCount - 1].Cells["G1Name"].Value = st.Level1GDescription;
                    grdList.Rows[grdList.RowCount - 1].Cells["G2Name"].Value = st.Level2GDescription;
                    grdList.Rows[grdList.RowCount - 1].Cells["G3Name"].Value = st.Level3GDescription;

                    total = total + (st.PresentStock * st.PurchasePrice);
                }
                btnTotalValue.Text = total.ToString();
                if (grdList.Rows.Count != 0 && Main.itemPriv[1] == true && (Main.itemPriv[2] == true || Main.itemPriv[3] == true))
                {
                    btnExportToExcel.Visible = true;
                }
                else
                {
                    btnExportToExcel.Visible = false;
                }
                grdList.Visible    = true;
                pnlgrdList.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Stock listing");
            }
        }
Пример #13
0
        private List <stock> getStockOrderedDetail()
        {
            List <stock> stockList    = new List <stock>();
            List <stock> substockList = new List <stock>();

            foreach (DataGridViewRow row in grdList.Rows)
            {
                substockList = StockDB.getStockDetailForStockIssue(row.Cells["StockItemID"].Value.ToString(),
                                                                   row.Cells["gModelNo"].Value.ToString(), Convert.ToDouble(row.Cells["IssueQuantity"].Value.ToString()));
                stockList.AddRange(substockList);
            }
            showStockListOrderedInGridView(stockList);
            return(stockList);
        }
Пример #14
0
    public static Stock[] GetByOrg(int organisation_id)
    {
        string    sql = JoinedSql + " AND s.organisation_id = " + organisation_id.ToString() + " ORDER BY o.name";
        DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0];

        Stock[] stockList = new Stock[tbl.Rows.Count];
        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            stockList[i]          = StockDB.Load(tbl.Rows[i], "s_");
            stockList[i].Offering = OfferingDB.Load(tbl.Rows[i], "o_");
        }

        return(stockList);
    }
Пример #15
0
    public static System.Collections.Hashtable GetHashByOrg(int org_id)
    {
        System.Collections.Hashtable orgOfferings = new System.Collections.Hashtable();

        DataTable dt_orgOfferings = StockDB.GetDataTable_ByOrg(org_id);

        for (int i = 0; i < dt_orgOfferings.Rows.Count; i++)
        {
            Stock curStock = StockDB.Load(dt_orgOfferings.Rows[i], "s_");
            curStock.Offering = OfferingDB.Load(dt_orgOfferings.Rows[i], "o_");
            orgOfferings[curStock.Offering.OfferingID] = curStock;
        }

        return(orgOfferings);
    }
Пример #16
0
        private void StockList(object sender, EventArgs e)
        {
            if (item_movementViewSource.View != null)
            {
                if (item_movementViewSource.View.CurrentItem != null)
                {
                    item_product _item_product = (item_movementViewSource.View.CurrentItem as item_movement).item_product;
                    if (_item_product != null && inventoryViewSource != null)
                    {
                        using (StockDB StockDB = new StockDB())
                        {
                            var movement =
                                (from items in StockDB.items
                                 join item_product in StockDB.item_product on items.id_item equals item_product.id_item
                                 into its
                                 from p in its
                                 join item_movement in StockDB.item_movement on p.id_item_product equals item_movement.id_item_product
                                 into IMS
                                 from a in IMS
                                 join AM in StockDB.app_branch on a.app_location.id_branch equals AM.id_branch
                                 where a.status == Status.Stock.InStock &&
                                 a.id_item_product == _item_product.id_item_product &&
                                 a.trans_date <= DateTime.Now &&
                                 a.app_location.id_branch == CurrentSession.Id_Branch
                                 group a by new { a.item_product, a.app_location }
                                 into last
                                 select new
                            {
                                code = last.Key.item_product.item.code,
                                name = last.Key.item_product.item.name,
                                location = last.Key.app_location.name,
                                itemid = last.Key.item_product.item.id_item,
                                quantity = last.Sum(x => x.credit) - last.Sum(x => x.debit),
                                id_item_product = last.Key.item_product.id_item_product,
                                measurement = last.Key.item_product.item.app_measurement.code_iso,
                                id_location = last.Key.app_location.id_location
                            }).ToList().OrderBy(y => y.name);

                            inventoryViewSource.Source = movement;
                        }
                    }
                }
            }
        }
Пример #17
0
        public void GetAllFromDatabase_ReturnResponce()
        {
            // Arrange
            // Create sample data
            var testData = new StockDB
            {
                Name        = "test-Stock",
                Price       = 1000,
                LastUpdated = "09/04/2020 10:36:52"
            };

            // Act
            // Test if mapper returns
            var result = _mapper.ToStockContract(testData);

            // Assert

            Assert.IsNotNull(result);
        }
Пример #18
0
    public static void UpdateAndCheckWarning(int organisation_id, int offering_id, int qtyUsed)
    {
        Organisation org      = OrganisationDB.GetByID(organisation_id);
        Offering     offering = OfferingDB.GetByID(offering_id);

        Stock[] stockList    = StockDB.GetByOrg(org.OrganisationID);
        string  warningEmail = SystemVariableDB.GetByDescr("StockWarningNotificationEmailAddress").Value;

        for (int i = 0; i < stockList.Length; i++)
        {
            if (offering.OfferingID == stockList[i].Offering.OfferingID && stockList[i].Quantity >= 0)
            {
                int prevQty = stockList[i].Quantity;
                int postQty = stockList[i].Quantity - qtyUsed;
                if (postQty < 0)
                {
                    postQty = 0;
                }

                if (warningEmail.Length > 0 && stockList[i].WarningAmount >= 0 && qtyUsed > 0 && stockList[i].WarningAmount < prevQty && stockList[i].WarningAmount >= postQty)
                {
                    try
                    {
                        Emailer.SimpleEmail(
                            warningEmail,
                            "Stock Warning Level Reached For " + stockList[i].Offering.Name + " at " + org.Name,
                            "This is an automated email to notify you that the stock warning level of <b>" + stockList[i].WarningAmount + "</b> items that was set for <b>" + stockList[i].Offering.Name + "</b> at <b>" + org.Name + "</b> has been reached and you may need to re-stock.<br /><br />Best regards,<br />Mediclinic",
                            true,
                            null,
                            null
                            );
                    }
                    catch (Exception ex)
                    {
                        Logger.LogException(ex, true);
                    }
                }

                StockDB.UpdateQuantity(stockList[i].StockID, postQty);
            }
        }
    }
Пример #19
0
        private void addGridListRows()
        {
            try
            {
                BOMDB    bomdb         = new BOMDB();
                string[] ProductStrArr = prod.Split('-');
                string   ProdID        = ProductStrArr[0];
                string   ProdName      = ProductStrArr[1];
                lblProductCode.Text  = ProdID;
                lblProductname.Text  = ProdName;
                bomList              = bomdb.getBOMDetail(ProdID);
                txtProdQuantity.Text = prodQuant.ToString();
                int QuantTOPrepare = Convert.ToInt32(txtProdQuantity.Text);
                lblModelNo.Text = ModelNo;
                foreach (bomdetail bom in bomList)
                {
                    string stockID    = bom.StockItemID;
                    double totalStock = StockDB.getTotalItemWiseStock(stockID, lblModelNo.Text);

                    grdList.Rows.Add();
                    grdList.Rows[grdList.Rows.Count - 1].Cells["SINO"].Value             = grdList.Rows.Count;
                    grdList.Rows[grdList.Rows.Count - 1].Cells["StockItemID"].Value      = bom.StockItemID;
                    grdList.Rows[grdList.Rows.Count - 1].Cells["StockItemName"].Value    = bom.Name;
                    grdList.Rows[grdList.Rows.Count - 1].Cells["gModelNo"].Value         = "NA";
                    grdList.Rows[grdList.Rows.Count - 1].Cells["RequiredQuantity"].Value = bom.Quantity * QuantTOPrepare;
                    grdList.Rows[grdList.Rows.Count - 1].Cells["StockQunatity"].Value    = totalStock;
                    if ((bom.Quantity * QuantTOPrepare) > totalStock)
                    {
                        grdList.Rows[grdList.Rows.Count - 1].Cells["IssueQuantity"].Value = totalStock;
                    }
                    else
                    {
                        grdList.Rows[grdList.Rows.Count - 1].Cells["IssueQuantity"].Value = bom.Quantity * QuantTOPrepare;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #20
0
        public void RabbitMQClient_Test()
        {
            // Arrange
            RabbitMQClient MQClient = new RabbitMQClient("Test_Queue", "stock.test");
            StockDB        stockDB  = new StockDB
            {
                Name        = "TESTNAME",
                Price       = 123.99f,
                LastUpdated = System.DateTime.Now.ToString()
            };

            // Act
            MQClient.SendMethod(stockDB, "stock.test");
            var response = ReceiveMessage();

            // Assert
            Assert.AreEqual(stockDB.Name, response.Name);
            Assert.AreEqual(stockDB.Price, response.Price);
            Assert.AreEqual(stockDB.LastUpdated, response.LastUpdated);
            // Clean-up
            MQClient.Close();
        }
Пример #21
0
    protected void GrdRegistration_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Insert"))
        {
            Organisation org = OrganisationDB.GetByID(GetFormID());
            if (org == null)
            {
                HideTableAndSetErrorMessage("");
                return;
            }

            DropDownList ddlOffering          = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewOffering");
            DropDownList ddlWarningAmount     = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewWarningAmount");
            DropDownList ddlQuantity_Zeros    = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewQuantity_Zeros");
            DropDownList ddlQuantity_Tens     = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewQuantity_Tens");
            DropDownList ddlQuantity_Hundreds = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewQuantity_Hundreds");

            try
            {
                Stock stock = StockDB.GetOfferingByOrgAndOffering(org.OrganisationID, Convert.ToInt32(ddlOffering.SelectedValue));
                if (stock == null)
                {
                    int qty = 100 * Convert.ToInt32(ddlQuantity_Hundreds.SelectedValue) + 10 * Convert.ToInt32(ddlQuantity_Tens.SelectedValue) + Convert.ToInt32(ddlQuantity_Zeros.SelectedValue);
                    StockDB.Insert(org.OrganisationID, Convert.ToInt32(ddlOffering.SelectedValue), qty, Convert.ToInt32(ddlWarningAmount.SelectedValue));
                    StockUpdateHistoryDB.Insert(org.OrganisationID, Convert.ToInt32(ddlOffering.SelectedValue), qty, true, false, Convert.ToInt32(Session["StaffID"]));
                }
            }
            catch (UniqueConstraintException)
            {
                // happens when 2 forms allow adding - do nothing and let form re-update
                ;
            }
            FillGrid();
            FillGridUpdateHistory();
        }
    }
Пример #22
0
        private void ListQtyDetails()
        {
            try
            {
                pnlList.Visible = true;
                grdList.Visible = true;
                grdList.Rows.Clear();
                ReportPOvsInvoiceQtyDB        sdb            = new ReportPOvsInvoiceQtyDB();
                List <reportpendingsupplyqty> qtylist        = ReportPendingSupplyDB.QtyList();
                List <TotalStock>             tStock         = StockDB.TotalStock(Main.MainStore);
                List <reportpendingsupplyqty> PendingSupList = ReportPendingSupplyDB.getPendingSupplyList();
                foreach (reportpendingsupplyqty poqty in qtylist)
                {
                    if (poqty.BalanceQty > 0)
                    {
                        try
                        {
                            grdList.Rows.Add();
                            grdList.Rows[grdList.RowCount - 1].Cells["StockItemID"].Value   = poqty.StockItemID;
                            grdList.Rows[grdList.RowCount - 1].Cells["StockItemName"].Value = poqty.StockItemName;
                            grdList.Rows[grdList.RowCount - 1].Cells["POQty"].Value         = poqty.POQty;
                            grdList.Rows[grdList.RowCount - 1].Cells["BilledQty"].Value     = poqty.BilledQty;
                            grdList.Rows[grdList.RowCount - 1].Cells["BalanceQty"].Value    = poqty.BalanceQty;

                            List <reportpendingsupplyqty> pList = PendingSupList.Where(x => x.StockItemID == poqty.StockItemID).ToList();
                            double total = pList.Sum(item => item.BalanceQty);
                            if (total != 0)
                            {
                                grdList.Rows[grdList.RowCount - 1].Cells["PendingPOQty"].Value = total; //For Pending Supply
                            }
                            else
                            {
                                grdList.Rows[grdList.RowCount - 1].Cells["PendingPOQty"].Value = Convert.ToDouble(0);
                            }
                            try
                            {
                                TotalStock tstk = tStock.Single(s => s.StockItemID == poqty.StockItemID);
                                if (tstk != null)
                                {
                                    grdList.Rows[grdList.RowCount - 1].Cells["PresentStock"].Value = tstk.Stock;
                                }
                                if (poqty.BalanceQty <= tstk.Stock)
                                {
                                    grdList.Rows[grdList.RowCount - 1].Cells["PresentStock"].Style.BackColor = Color.Yellow;
                                }
                            }
                            catch (Exception ex)
                            {
                                grdList.Rows[grdList.RowCount - 1].Cells["PresentStock"].Value = Convert.ToDouble(0);
                            }
                            double qtytobeproceured = 0.0;
                            try
                            {
                                qtytobeproceured =
                                    Convert.ToDouble(grdList.Rows[grdList.RowCount - 1].Cells["BalanceQty"].Value) -
                                    (Convert.ToDouble(grdList.Rows[grdList.RowCount - 1].Cells["PresentStock"].Value) +
                                     Convert.ToDouble(grdList.Rows[grdList.RowCount - 1].Cells["PendingPOQty"].Value));
                            }
                            catch (Exception ex)
                            {
                                qtytobeproceured = 0.0;
                            }
                            if (qtytobeproceured > 0)
                            {
                                grdList.Rows[grdList.RowCount - 1].Cells["QtyToBeProcured"].Value = qtytobeproceured;
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
                if (grdList.RowCount > 0)
                {
                    txtSearch.Visible        = true;
                    lblSearch.Visible        = true;
                    btnExportToExcel.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Stock listing");
            }
        }
Пример #23
0
 public void SendMethod(StockDB stockDB, string routingKey)
 {
     SendMessage(Serialize(stockDB), routingKey);
 }