private void Search()
    {
        try
        {
            Location loc = new Location();
            loc.BranchCode = "";
            loc.BranchName = "";
            loc.IsActive = true;
            DataSet dsBranch = new LocationsDAO().SearchLocation(loc);

            //DataSet dsBranch = new LocationsDAO().GetAllBranches();

            if (dsBranch != null && dsBranch.Tables.Count > 0)
            {

                gvBranches.DataSource = dsBranch;
                gvBranches.DataBind();
                trGrid.Visible = true;
                trNoRecords.Visible = false;
            }
            else
            {

                trNoRecords.Visible = true;
                trGrid.Visible = false;
            }

        }
        catch (Exception ex)
        {

            throw ex;
        }
    }
示例#2
0
    /// <summary>
    /// Generates the transfer details for the invoice
    /// </summary>
    /// <returns></returns>
    private bool GenerateTransferNote()
    {
        try
        {
            bool result = true;
            foreach (DataRow dr in ObjInv.DsInvoiceDetails.Tables[0].Rows)
            {
                if (dr["ItemId"] == null)//If Group item
                {
                    continue;
                }
                Int32 itemId = Int32.Parse(dr["ItemId"].ToString().Trim());

                Item item = new Item();
                item.ItemId = itemId;
                item.GetItemsByItemIDAndBranchID(Int32.Parse(Constant.MainStoreId));//Gets stock for main store only
                Int32 itemCount = Int32.Parse(dr["Quantity"].ToString().Trim());
                Int32 TransferQty = (Int32)item.QuantityInHand - (item.InvoicedQty + itemCount);
                if (TransferQty >= 0)
                {
                    continue;
                }
                else
                {
                    TransferQty = TransferQty * -1;// Make TransferQty possitive value
                }

                LocationStocks locStock = new LocationStocks();
                locStock.ItemId = itemId;

                DataSet dsItemSummary = new LocationsDAO().GetLocationStocksByItem(locStock);

                foreach (DataRow drIS in dsItemSummary.Tables[0].Rows)
                {
                    Int32 branchId = Int32.Parse(drIS["BranchId"].ToString().Trim());
                    if (branchId.ToString()==Constant.MainStoreId)
                    {
                        continue;
                    }
                    Int32 Stock = Int32.Parse(drIS["QuantityInHand"].ToString().Trim());
                    if (Stock - TransferQty >= 0)
                    {
                        txtTransferNote.Value += String.Format(Constant.MSG_Invoice_Transfer_Details, item.ItemCode, drIS["BranchCode"].ToString().Trim(), TransferQty.ToString());
                        break;
                    }
                    else
                    {
                        txtTransferNote.Value += String.Format(Constant.MSG_Invoice_Transfer_Details, item.ItemCode, drIS["BranchCode"].ToString().Trim(), Stock.ToString());
                        TransferQty = TransferQty - Stock;
                        continue;
                    }
                }

                if (TransferQty > 0)
                {
                    result = false;
                    break;
                }
                else
                {
                    result = true;
                }
            }
            return result;
        }
        catch (Exception ex)
        {

            throw ex;
        }
    }