private void LoadWareouses()
        {
            layoutWarehouse.ContentVisible = true;
            lkWarehouse.Visible            = true;
            var listOfWarehouse = new List <BLL.Warehouse>();
            var listofWsData    = new DataTable();

            foreach (DataRow row in _allItemsToBeCorrected.Rows)
            {
                if (!listOfWarehouse.Exists(w => w.ID == Convert.ToInt32(row["WearehouseID"])))
                {
                    var newWarehouse = new BLL.Warehouse();
                    newWarehouse.LoadByPrimaryKey(Convert.ToInt32(row["WearehouseID"]));
                    listOfWarehouse.Add(newWarehouse);
                }
            }
            if (listOfWarehouse.Count > 1)
            {
                listofWsData = ToDataTable(listOfWarehouse);
                listofWsData.Rows.Add(-1, "All");
                lkWarehouse.EditValue = -1; //select All
            }
            if (listofWsData.Rows.Count == 0)
            {
                listofWsData = ToDataTable(listOfWarehouse);
            }
            lkWarehouse.Properties.DataSource = listofWsData;
        }
 /// <summary>
 /// Gets the warehouse with cluster.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 /// <returns></returns>
 public static DataView GetWarehouseWithCluster(int userID)
 {
     string query =
     HCMIS.Repository.Queries.Warehouse.SelectGetWarehouseWithCluster(userID);
     BLL.Warehouse phStore = new Warehouse();
     phStore.LoadFromRawSql(query);
     return phStore.DefaultView;
 }
        private void BinCardTransactionLoad(object sender, EventArgs e)
        {
            Item itm = new Item();
            itm.LoadByPrimaryKey(_ItemID);
            txtItemName.Text = txtitmName.Text = itm.FullItemName;
            this.Text = string.Format("{0} Detail Report", itm.FullItemName);

            BLL.Warehouse clusters = new BLL.Warehouse();
            clusters.LoadUsersClustersContainingItem(CurrentContext.UserId, _ItemID, _UnitID.Value, _StoreID);
            lkWarehouses.Properties.DataSource = clusters.DefaultView;
            lkWarehouses.ItemIndex = 0;

            lkBinCardWarehouse.Properties.DataSource = clusters.DefaultView;
            lkBinCardWarehouse.ItemIndex = 0;

            lblItemID.Text = this._ItemID.ToString();
            lblItemSerialNumber.Text = itm.SerialNumber;

            lkYear.Properties.DataSource = itm.AllYears();
            lkYear.EditValue = _Year;

            lkWarehouses_EditValueChanged(null, null);

            ItemUnit iu = new ItemUnit();
            iu.LoadByPrimaryKey(_UnitID.Value);
            lblBUnit.Text = iu.Text;

            dtDate.Value = DateTimeHelper.ServerDateTime;
            dtDate.CustomFormat = "MM/dd/yyyy";
            dtCurrent = ConvertDate.DateConverter(dtDate.Text);

            Activity stor = new Activity();
            stor.LoadByPrimaryKey(_StoreID);

            BindLocationView();

            if (CurrentContext.LoggedInUser.UserType == UserType.Constants.FINANCE ||
                CurrentContext.LoggedInUser.UserType == UserType.Constants.FUND_OFFICER)
            {
                tbClassicBinCard.Text = "Stock Card";
            }
            else
            {
                colTotalCost.Visible = false;
                colUnitCost.Visible = false;
                tbSOHPriceSummary.Visible = false;
            }

            if (this.HasPermission("Show-Classic-Bin-Card"))
            {
                tbClassicBinCard.Visible = false;
            }
            if (this.HasPermission("Show-Bin-Card"))
            {
                tbBinCard.Visible = false;
            }
        }
Esempio n. 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (XtraMessageBox.Show("Are you sure you would like to change the status of this store/warehouse?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            DataTable table = gridManageInvetoryView.GetFocusedDataRow().Table;

            foreach (DataRow dr in table.Rows)
            {
                if (dr != null && dr.RowState == DataRowState.Modified)
                {
                    var freezChoice = Convert.ToString(ComboBoxFreezChoice.Text);

                    if (freezChoice == "Cluster")
                    {
                        int     selected = Convert.ToInt32(dr["LocationID"]);
                        Cluster cluster  = new Cluster();
                        cluster.LoadByPrimaryKey(selected);
                        cluster.IsActive = Convert.ToBoolean(dr["Status"]);
                        cluster.Save();
                        this.LogActivity("Changed Status of Cluster");
                        BLL.Warehouse warehouse = new BLL.Warehouse();
                        warehouse.UpdateWarehouseStatusbyCluster(selected, Convert.ToBoolean(dr["Status"]));

                        BLL.PhysicalStore physicalStore = new PhysicalStore();
                        physicalStore.UpdatePhysicalStoreStatusbyCluster(selected, Convert.ToBoolean(dr["Status"]));
                    }

                    else if (freezChoice == "Warehouse")
                    {
                        int           selected  = Convert.ToInt32(dr["LocationID"]);
                        BLL.Warehouse warehouse = new BLL.Warehouse();
                        warehouse.LoadByPrimaryKey(selected);
                        warehouse.IsActive = Convert.ToBoolean(dr["Status"]);
                        warehouse.Save();
                        this.LogActivity("Changed Status of Warehouse");
                        BLL.PhysicalStore physicalStore = new PhysicalStore();
                        physicalStore.UpdatePhysicalStoreStatusbyWarehouse(selected, Convert.ToBoolean(dr["Status"]));
                    }
                    else if (freezChoice == "Physical Store")
                    {
                        int           selected      = Convert.ToInt32(dr["LocationID"]);
                        PhysicalStore physicalStore = new PhysicalStore();
                        physicalStore.LoadByPrimaryKey(selected);
                        physicalStore.IsActive = Convert.ToBoolean(dr["Status"]);
                        physicalStore.Save();
                        this.LogActivity("Changed Status of Store");
                    }
                }
            }


            XtraMessageBox.Show("The freezing and unfreezing you have made have been saved.", "Successfully Saved",
                                MessageBoxButtons.OK);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (XtraMessageBox.Show("Are you sure you would like to change the status of this store/warehouse?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            DataTable table = gridManageInvetoryView.GetFocusedDataRow().Table;
            foreach(DataRow dr in table.Rows)
            {
                if (dr != null && dr.RowState == DataRowState.Modified)
                {
                    var freezChoice = Convert.ToString(ComboBoxFreezChoice.Text);

                    if (freezChoice == "Cluster")
                    {
                        int selected = Convert.ToInt32(dr["LocationID"]);
                        Cluster cluster = new Cluster();
                        cluster.LoadByPrimaryKey(selected);
                        cluster.IsActive = Convert.ToBoolean(dr["Status"]);
                        cluster.Save();
                        this.LogActivity("Changed Status of Cluster");
                        BLL.Warehouse warehouse = new BLL.Warehouse();
                        warehouse.UpdateWarehouseStatusbyCluster(selected, Convert.ToBoolean(dr["Status"]));

                        BLL.PhysicalStore physicalStore = new PhysicalStore();
                        physicalStore.UpdatePhysicalStoreStatusbyCluster(selected, Convert.ToBoolean(dr["Status"]));
                    }

                    else if (freezChoice == "Warehouse")
                    {
                        int selected = Convert.ToInt32(dr["LocationID"]);
                        BLL.Warehouse warehouse = new BLL.Warehouse();
                        warehouse.LoadByPrimaryKey(selected);
                        warehouse.IsActive = Convert.ToBoolean(dr["Status"]);
                        warehouse.Save();
                        this.LogActivity("Changed Status of Warehouse");
                        BLL.PhysicalStore physicalStore = new PhysicalStore();
                        physicalStore.UpdatePhysicalStoreStatusbyWarehouse(selected, Convert.ToBoolean(dr["Status"]));
                    }
                    else if (freezChoice == "Physical Store")
                    {
                        int selected = Convert.ToInt32(dr["LocationID"]);
                        PhysicalStore physicalStore = new PhysicalStore();
                        physicalStore.LoadByPrimaryKey(selected);
                        physicalStore.IsActive = Convert.ToBoolean(dr["Status"]);
                        physicalStore.Save();
                        this.LogActivity("Changed Status of Store");
                    }

                }
            }

            XtraMessageBox.Show("The freezing and unfreezing you have made have been saved.", "Successfully Saved",
                                MessageBoxButtons.OK);
        }
        public static bool CheckOutStandingIssues(int warehouseID = 0)
        {
            Warehouse warehouse = new Warehouse();
            warehouse.LoadAll();

            string query =
                HCMIS.Repository.Queries.IssueDoc.SelectCheckOutStandingIssues(warehouseID, warehouse.RowCount,
                                                                               OrderStatus.Constant.ORDER_APPROVED,
                                                                               OrderStatus.Constant.ISSUED);
            IssueDoc issueDoc = new IssueDoc();
            issueDoc.LoadFromRawSql(query);
            return issueDoc.Getint("count") == 0;
        }
        public static StockCardReport CreateStockCard(int activityID, int itemID, int unitID, int warehouse, int manufactuererID, DateTime? startDate = null, DateTime? endDate = null)
        {
            BLL.Balance balance = new Balance();

            BLL.Item item = new Item();
            item.LoadByPrimaryKey(itemID);

            ItemUnit iunit = new ItemUnit();
            iunit.LoadByPrimaryKey(unitID);

            BLL.Warehouse physicalStore = new Warehouse();
            physicalStore.LoadByPrimaryKey(warehouse);
            var dataView = new DataView();

            if(startDate == null || endDate == null)
            {
                dataView = Balance.GetStockCardByWarehouse(activityID, itemID, unitID, EthiopianDate.EthiopianDate.Now.FiscalYear,
                                          warehouse, manufactuererID);
            }
            else
            {
                dataView = Balance.GetStockCardByDate(activityID, itemID, unitID, warehouse, manufactuererID,
                                                      startDate.Value, endDate.Value);

            }
            StockCardReport report = new StockCardReport();
            report.DataSource = dataView;

            // Bind the headers here.
            report.StockCode.Text = item.StockCode;
            report.Description.Text = item.FullItemName;
            report.Unit.Text = iunit.Text;

            Activity store = new Activity();
            store.LoadByPrimaryKey(activityID);
            report.Account.Text = store.AccountName;
            report.SubAccount.Text = store.SubAccountName;
            report.Activity.Text = store.Name;

            Manufacturer manufacturers = new Manufacturer();
            manufacturers.LoadByPrimaryKey(manufactuererID);
            report.Manufacturer.Text = manufacturers.Name;
            // TODO: add the Item Source Here (the suggested interpretation is that item source is supplier)
            report.PrintedBy.Text = string.Format("Generated By: {0} On {1}", CurrentContext.LoggedInUserName,
                                                  BLL.DateTimeHelper.ServerDateTime.ToString("dd-MM-yyyy hh:mm tt"));
            report.Store.Text = physicalStore.Name;

            report.AppVersion.Text = "HCMIS";
            return report;
        }
        /// <summary>
        /// Formats the STV.
        /// </summary>
        /// <param name="ord">The ord.</param>
        /// <param name="dvPriced">The dv priced.</param>
        /// <param name="stvSentTo">The STV sent to.</param>
        /// <param name="pl">The pl.</param>
        /// <param name="deliveryNote">if set to <c>true</c> [delivery note].</param>
        /// <param name="allowCancelByUser">if set to <c>true</c> [allow cancel by user].</param>
        /// <exception cref="System.Exception"></exception>
        private XtraReport FormatSTV(Order ord, DataTable dvPriced, string stvSentTo, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService, int orderID)
        {
            bool hasInsurance = chkIncludeInsurance.Checked;
            string accountName = txtConfirmFromStore.Text;
            string transferType = null;

            int? orderTypeID = null;
            BLL.Order order = new Order();
            order.LoadByPrimaryKey(orderID);

            if (!order.IsColumnNull("OrderTypeID"))
                orderTypeID = Convert.ToInt32(ord.GetColumn("OrderTypeID"));
            string transferDetail = "";
            if (orderTypeID.HasValue)
            {
                BLL.Transfer transfer = new Transfer();

                if (orderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER)
                {
                    transfer.LoadByOrderID(orderID);
                    PhysicalStore toStore = new PhysicalStore();
                    toStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID);
                    BLL.Warehouse toWarehouse = new BLL.Warehouse();
                    toWarehouse.LoadByPrimaryKey(toStore.PhysicalStoreTypeID);
                    transferType = "Store to Store Transfer";
                    stvSentTo = toWarehouse.Name;
                }

                if (orderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER)
                {
                    transfer.LoadByOrderID(orderID);
                    Activity fromActivity = new Activity();
                    fromActivity.LoadByPrimaryKey(transfer.FromStoreID);
                    Activity toActivity = new Activity();
                    toActivity.LoadByPrimaryKey(transfer.ToStoreID);
                    transferType = "Account to Account Transfer";
                    transferDetail = string.Format("From: {0} To: {1}", fromActivity.FullActivityName, toActivity.FullActivityName);
                }
            }

            if (!deliveryNote)
            {
                if(InstitutionIType.IsVaccine(GeneralInfo.Current))
                {
                    return WorkflowReportFactory.CreateModel22(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType);
                }
                var stvReport = WorkflowReportFactory.CreateSTVonHeadedPaper(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType);
                if (transferDetail != "")
                {
                    stvReport.TransferDetails.Text = transferDetail;
                    stvReport.TransferDetails.Visible = true;
                }
                else
                {
                    stvReport.TransferDetails.Visible = false;
                }

                return stvReport;
            }
            else
            {
                return WorkflowReportFactory.CreateDeliveryNote(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType);

            }
        }
Esempio n. 9
0
        private void gridReceiveView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            // Bind the detail grid
            PalletLocation pl = new PalletLocation();

            if (e != null && e.PrevFocusedRowHandle < -1)
            {
                return;
            }

            try
            {
                DataRow dr = gridReceiveView.GetFocusedDataRow();

                if (dr == null)
                {
                    return;
                }

                ReceiptID = Convert.ToInt32(dr["ReceiptID"]);
                BLL.Receipt receiptDoc = new BLL.Receipt();
                receiptDoc.LoadByPrimaryKey(ReceiptID);

                DataTable GRNFDetail = receiptDoc.GetDetailsForGRNF();


                if (GRNFDetail.Rows.Count > 0)
                {
                    //var store = new Store();
                    //store.
                    BLL.PO order = new BLL.PO();
                    //var Mode = new Mode();
                    //Mode.LoadByPrimaryKey(order.ModeID);
                    //lblMode.Text = Mode.TypeName;
                    HeaderSection.Text = GRNFDetail.Rows[0]["PONumber"].ToString();


                    lblRecieveStatus.Text     = dr["recieveStatus"].ToString();
                    lblReceiptNo.Text         = dr["ReceiptNo"].ToString();
                    lblRecievedBy.Text        = dr["ReceivedBy"].ToString();
                    lblRecievedDate.Text      = Convert.ToDateTime(dr["Date"]).ToShortDateString();
                    lblReciveType.Text        = (dr["ReceiveType"]).ToString();
                    lblWayBill.Text           = (dr["WayBillNo"]).ToString() != "" ? dr["WayBillNo"].ToString() : "-";
                    lblTransferVoucherNo.Text = (dr["transferNo"]).ToString() != "" ? dr["transferNo"].ToString() : "-";

                    var warehouse = new BLL.Warehouse();
                    warehouse.LoadByPrimaryKey(receiptDoc.WarehouseID);
                    lblWarehouse.Text = warehouse.Name;
                    lblSupplier.Text  = dr["Supplier"].ToString();

                    var cluster = new BLL.Cluster();
                    cluster.LoadByPrimaryKey(warehouse.ClusterID);
                    lblCluster.Text = cluster.Name;



                    lblDocType.Text = "";

                    lblPoType.Text = dr["POType"].ToString();
                    //var ps = new BLL.PhysicalStore();
                    //ps.LoadByPrimaryKey(order.p);
                    //lblStore.Text = ps.Name;


                    txtOrderNo.EditValue = GRNFDetail.Rows[0]["PONumber"];
                    lblPoNumber.Text     = GRNFDetail.Rows[0]["PONumber"].ToString();

                    lblInvoiceNumber.Text = receiptDoc.STVOrInvoiceNo;

                    lblInsurancePolicy.Text = receiptDoc.InsurancePolicyNo != ""?receiptDoc.InsurancePolicyNo : "-";

                    var activity = new Activity();
                    activity.LoadByPrimaryKey(Convert.ToInt32(GRNFDetail.Rows[0]["ActivityID"]));

                    txtActivity.EditValue = activity.FullActivityName;
                    lblActivity.Text      = activity.Name;

                    lblSubAccount.Text = activity.SubAccountName;
                    lblMode.Text       = activity.ModeName;
                    lblAccount.Text    = activity.AccountName;

                    gridDetails.DataSource = GRNFDetail;
                }

                if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
                {
                    gridShortage.DataSource = receiptDoc.GetDiscrepancyForGRNF();
                }
            }

            catch
            {
                gridDetails.DataSource = null;
            }
        }
Esempio n. 10
0
        private void BinCardTransactionLoad(object sender, EventArgs e)
        {
            Item itm = new Item();

            itm.LoadByPrimaryKey(_ItemID);
            txtItemName.Text = txtitmName.Text = itm.FullItemName;
            this.Text        = string.Format("{0} Detail Report", itm.FullItemName);

            BLL.Warehouse clusters = new BLL.Warehouse();
            clusters.LoadUsersClustersContainingItem(CurrentContext.UserId, _ItemID, _UnitID.Value, _StoreID);
            lkWarehouses.Properties.DataSource = clusters.DefaultView;
            lkWarehouses.ItemIndex             = 0;

            lkBinCardWarehouse.Properties.DataSource = clusters.DefaultView;
            lkBinCardWarehouse.ItemIndex             = 0;

            lblItemID.Text           = this._ItemID.ToString();
            lblItemSerialNumber.Text = itm.SerialNumber;

            lkYear.Properties.DataSource = itm.AllYears();
            lkYear.EditValue             = _Year;

            lkWarehouses_EditValueChanged(null, null);

            ItemUnit iu = new ItemUnit();

            iu.LoadByPrimaryKey(_UnitID.Value);
            lblBUnit.Text = iu.Text;


            dtDate.Value        = DateTimeHelper.ServerDateTime;
            dtDate.CustomFormat = "MM/dd/yyyy";
            dtCurrent           = ConvertDate.DateConverter(dtDate.Text);



            Activity stor = new Activity();

            stor.LoadByPrimaryKey(_StoreID);

            BindLocationView();

            if (CurrentContext.LoggedInUser.UserType == UserType.Constants.FINANCE ||
                CurrentContext.LoggedInUser.UserType == UserType.Constants.FUND_OFFICER)
            {
                tbClassicBinCard.Text = "Stock Card";
            }
            else
            {
                colTotalCost.Visible      = false;
                colUnitCost.Visible       = false;
                tbSOHPriceSummary.Visible = false;
            }

            if (this.HasPermission("Show-Classic-Bin-Card"))
            {
                tbClassicBinCard.Visible = false;
            }
            if (this.HasPermission("Show-Bin-Card"))
            {
                tbBinCard.Visible = false;
            }
        }
        /// <summary>
        /// Gets the pick list details for order.
        /// </summary>
        /// <param name="ordID">The ord ID.</param>
        /// <param name="Preparedby">The preparedby.</param>
        /// <returns></returns>
        public DataView GetPickListDetailsForOrder(int ordID, string Preparedby)
        {
            this.LoadByOrderID(ordID);
            var query = HCMIS.Repository.Queries.PickList.SelectGetPickListDetailsForOrder(this.ID);
            this.LoadFromRawSql(query);
            // Add important columns
            this.DataTable.Columns.Add("SKUTOPICK", typeof(decimal));
            this.DataTable.Columns.Add("SKUPICKED", typeof(decimal));
            this.DataTable.Columns.Add("BUPICKED", typeof(decimal));
            this.DataTable.Columns.Add("BoxSizeDisplay");
            this.DataTable.Columns.Add("SKUBU", typeof(decimal));
            this.DataTable.Columns.Add("IsManufacturerLocal", typeof(bool));
            this.DataTable.Columns.Add("PrintedSTVNumber", typeof(string));
            this.DataTable.Columns.Add("PhysicalStoreName", typeof(string));
            this.DataTable.Columns.Add("PhysicalStoreTypeID", typeof(int));
            this.DataTable.Columns.Add("PhysicalStoreTypeName", typeof(string));
            this.DataTable.Columns.Add("PreparedBy", typeof(string));
            int i = 1;
            while (!this.EOF)
            {
                decimal packs = Convert.ToDecimal(this.GetColumn("Packs"));

                int manufacturer = Convert.ToInt32(this.GetColumn("ManufacturerID"));
                Manufacturer m = new Manufacturer();
                m.LoadByPrimaryKey(manufacturer);
                if (!m.IsColumnNull("CountryOfOrigin") && m.CountryOfOrigin.Contains("Ethiopia"))
                    this.SetColumn("IsManufacturerLocal", true);
                else
                    this.SetColumn("IsManufacturerLocal", false);

                int recPalletID = Convert.ToInt32(this.GetColumn("ReceivePalletID"));
                ReceivePallet rp = new ReceivePallet();
                rp.LoadByPrimaryKey(recPalletID);
                try
                {
                    ReceiveDoc receiveDoc = new ReceiveDoc();
                    Receipt receipt = new Receipt();
                    receiveDoc.LoadByPrimaryKey(rp.ReceiveID);
                    receipt.LoadByPrimaryKey(receiveDoc.ReceiptID);
                    this.SetColumn("PhysicalStoreName", rp.GetPhysicalStoreName());
                    int physicalStoreTypeID = rp.GetPhysicalStoreTypeID();
                    this.SetColumn("PhysicalStoreTypeID", physicalStoreTypeID);
                    Warehouse phyStoreType = new Warehouse();
                    phyStoreType.LoadByPrimaryKey(physicalStoreTypeID);
                    this.SetColumn("PhysicalStoreTypeName", phyStoreType.Name);
                    if (BLL.Settings.PrintUserNameOnInvoice)
                    {
                        this.SetColumn("PreparedBy", Preparedby);
                    }

                }
                catch
                {

                }

                int itemId = Convert.ToInt32(this.GetColumn("ItemID"));
                int boxLevel = Convert.ToInt32(this.GetColumn("BoxLevel"));
                decimal qtyPerPack = this.Getint("QtyPerPack");
                //im.LoadIMbyLevel(itemId, manufacturer, boxLevel);
                this.SetColumn("SKUTOPICK", (packs));
                this.SetColumn("SKUPICKED", this.GetColumn("SKUTOPICK"));
                // TODO:show the box size here for Program store
                this.SetColumn("BoxSizeDisplay", "");
                this.SetColumn("SKUBU", qtyPerPack);
                this.SetColumn("BUPICKED", qtyPerPack * Convert.ToDecimal(this.GetColumn("SKUPICKED")));
                this.SetColumn("LineNum", i++);
                if (this.IsColumnNull("DeliveryNote"))
                {
                    this.SetColumn("DeliveryNote", false);
                }
                this.MoveNext();
            }
            return this.DefaultView;
        }
        //,bool pricedItems)
        /// <summary>
        /// Gets picked order detail for item (Used by the IssueLog)
        /// </summary>
        /// <param name="ordID"></param>
        /// <param name="storeid"></param>
        /// <param name="pricedItems">True - For Priced Items Only, False - For Delivery Notes Only</param>
        /// <returns></returns>
        public DataView GetPickedOrderDetailForOrder(int stvLogID, bool includeDeleted)
        {
            string query;

            // remove this line ...
            // check if this has changed the dn to stv conversion
            // (pld.DeliveryNote is null or pld.DeliveryNote = 0 or (pld.DeliveryNote=1 and pld.UnitPrice<>0)) and
            query = HCMIS.Repository.Queries.PickList.SelectGetPickedOrderDetailForOrder(stvLogID);
            if (includeDeleted)
            {
                query = HCMIS.Repository.Queries.PickList.SelectGetPickedOrderDetailForOrderIncludeDeleted(stvLogID);
            }

            this.LoadFromRawSql(query);
            // Add important columns
            this.DataTable.Columns.Add("SKUTOPICK", typeof(int));
            this.DataTable.Columns.Add("SKUPICKED", typeof(int));
            this.DataTable.Columns.Add("BUPICKED", typeof(int));
            this.DataTable.Columns.Add("BoxSizeDisplay");
            this.DataTable.Columns.Add("SKUBU", typeof(int));
            this.DataTable.Columns.Add("IsManufacturerLocal", typeof(bool));
            this.DataTable.Columns.Add("PrintedSTVNumber", typeof(string));
            this.DataTable.Columns.Add("PhysicalStoreName", typeof(string));
            this.DataTable.Columns.Add("PhysicalStoreTypeID", typeof(int));
            this.DataTable.Columns.Add("PhysicalStoreTypeName", typeof(string));

            ItemManufacturer im = new ItemManufacturer();
            int i = 1;
            while (!this.EOF)
            {
                int packs = Convert.ToInt32(this.GetColumn("Packs"));
                int manufacturer = Convert.ToInt32(this.GetColumn("ManufacturerID"));
                Manufacturer m = new Manufacturer();
                m.LoadByPrimaryKey(manufacturer);
                if (!m.IsColumnNull("CountryOfOrigin") && m.CountryOfOrigin == "Ethiopia")
                    this.SetColumn("IsManufacturerLocal", true);
                else
                    this.SetColumn("IsManufacturerLocal", false);

                int recPalletID = Convert.ToInt32(this.GetColumn("ReceivePalletID"));
                ReceivePallet rp = new ReceivePallet();
                rp.LoadByPrimaryKey(recPalletID);
                try
                {
                    this.SetColumn("PhysicalStoreName", rp.GetPhysicalStoreName());
                    int physicalStoreTypeID = rp.GetPhysicalStoreTypeID();
                    this.SetColumn("PhysicalStoreTypeID", physicalStoreTypeID);
                    Warehouse phyStoreType = new Warehouse();
                    phyStoreType.LoadByPrimaryKey(physicalStoreTypeID);
                    this.SetColumn("PhysicalStoreTypeName", phyStoreType.Name);
                }
                catch
                {
                }

                int itemId = Convert.ToInt32(this.GetColumn("ItemID"));
                int boxLevel = Convert.ToInt32(this.GetColumn("BoxLevel"));
                int qtyPerPack = this.Getint("QtyPerPack");
                //im.LoadIMbyLevel(itemId, manufacturer, boxLevel);
                this.SetColumn("SKUTOPICK", (packs));
                this.SetColumn("SKUPICKED", this.GetColumn("SKUTOPICK"));
                // TODO:show the box size here for Program store
                this.SetColumn("BoxSizeDisplay", "");
                this.SetColumn("SKUBU", qtyPerPack);
                this.SetColumn("BUPICKED", qtyPerPack * Convert.ToInt32(this.GetColumn("SKUPICKED")));
                this.SetColumn("LineNum", i++);
                this.MoveNext();

            }
            return this.DefaultView;
        }
        private void gridReceiveView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            // Bind the detail grid
            PalletLocation pl = new PalletLocation();
            try
            {
                ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);
                BLL.Receipt receiptDoc = new BLL.Receipt();
                var rd = new ReceiveDoc();
                rd.LoadByReceiptID(ReceiptID);

                var ps = new PhysicalStore();
                ps.LoadByPrimaryKey(rd.PhysicalStoreID);

                var w = new BLL.Warehouse();
                w.LoadByPrimaryKey(ps.PhysicalStoreTypeID);
                lblWarehouse.Text = w.Name ?? "-";

                var c = new Cluster();
                c.LoadByPrimaryKey(w.ClusterID);
                lblCluster.Text = c.Name ?? "-";

                receiptDoc.LoadByPrimaryKey(ReceiptID);
                DataTable GRNFDetail =  receiptDoc.GetDetailsForGRNF();
                gridDetails.DataSource = GRNFDetail;
                gridShortage.DataSource = receiptDoc.GetDiscrepancyForGRNF();
                int status = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["Status"]);

                var SelectGRV = gridReceiveView.GetFocusedDataRow();

                lblMode.Text = (string)SelectGRV["ModeName"];
                lblAccount.Text = (string)SelectGRV["AccountName"];
                lblSubAccount.Text = (string)SelectGRV["SubAccountName"];
                lblActivity.Text = (string)SelectGRV["ActivityName"];
                lblSupplier.Text = (string)SelectGRV["SupplierName"];
                lblPONumber.Text = (string)SelectGRV["PONo"];

                lblType.Text = (string)SelectGRV["ReceiptType"];
                lblStatus.Text = (string)SelectGRV["CurrentStatus"];

                var lgs = new LogReceiptStatus();
                lgs.LoadByReceiptID(ReceiptID);

                lblCalculatedDate.Text = lgs.StatusChangedDate.ToShortDateString();

                var user = new User();
                if (SelectGRV["calculatedBy"] != DBNull.Value)
                {
                    user.LoadByPrimaryKey(Convert.ToInt32(SelectGRV["calculatedBy"]));
                    lblCalculatedBy.Text = user.FullName;
                }

                else
                {
                    lblCalculatedBy.Text = "-";
                }

                lblCostConfirmedBy.Text = SelectGRV["confirmedBy"] != DBNull.Value ? SelectGRV["confirmedBy"].ToString() : "-";

                //lblGRVNumber.Text = reference;
                //lblRecivedDate.Text = ((DateTime)SelectGRV["Date"]).ToShortDateString();
                lblCostConfirmedDate.Text = SelectGRV["confirmedDate"] != DBNull.Value ? Convert.ToDateTime(SelectGRV["confirmedDate"]).ToShortDateString() : "-";

                string s = "";

                int length = ((string)SelectGRV["STVOrInvoiceNo"]).Length;
                string grv = (Convert.ToInt32(SelectGRV["IDPrinted"])).ToString();
                HeaderGroup.Text = "Invoice No: " + (string)SelectGRV["STVOrInvoiceNo"] + s.PadRight(240 - length) + "GRV No: " + grv ;

                //ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);
                //ds = new DataSet();
                //DataTable dvMaster = pl.GetDetailsOfByReceiptID(ReceiptID);
                //dvMaster.TableName = "Master";
                //ds.Tables.Add(dvMaster);
                //gridDetails.DataSource = ds.Tables[dvMaster.TableName];

                //var receipt = new BLL.Receipt();
                //receipt.LoadByPrimaryKey(ReceiptID);
                //int receiptTypeID = receipt.ReceiptTypeID;

                if (currentMode == Modes.GRVPrinting)
                {
                    if (status != ReceiptConfirmationStatus.Constants.PRICE_CONFIRMED)
                    {
                        gridDetails.Enabled = false;

                        btnConfirm.Enabled = false;
                        btnPrint.Enabled = false;
                        btnReturn.Enabled = false;
                    }
                    else
                    {
                        gridDetails.Enabled = true;
                        btnConfirm.Enabled = true;
                        btnPrint.Enabled = true;
                        btnReturn.Enabled = true;
                    }
                }
            }

            catch
            {
                gridDetails.DataSource = null;
                gridShortage.DataSource = null;
            }
        }
        /// <summary>
        /// Formats the STV.
        /// </summary>
        /// <param name="ord">The ord.</param>
        /// <param name="dvPriced">The dv priced.</param>
        /// <param name="stvSentTo">The STV sent to.</param>
        /// <param name="pl">The pl.</param>
        /// <param name="deliveryNote">if set to <c>true</c> [delivery note].</param>
        /// <param name="allowCancelByUser">if set to <c>true</c> [allow cancel by user].</param>
        /// <exception cref="System.Exception"></exception>
        private XtraReport FormatSTV(Order ord, DataTable dvPriced, string stvSentTo, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService, int orderID)
        {
            bool   hasInsurance = chkIncludeInsurance.Checked;
            string accountName  = txtConfirmFromStore.Text;
            string transferType = null;

            int?orderTypeID = null;

            BLL.Order order = new Order();
            order.LoadByPrimaryKey(orderID);

            if (!order.IsColumnNull("OrderTypeID"))
            {
                orderTypeID = Convert.ToInt32(ord.GetColumn("OrderTypeID"));
            }
            string transferDetail = "";

            if (orderTypeID.HasValue)
            {
                BLL.Transfer transfer = new Transfer();

                if (orderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER)
                {
                    transfer.LoadByOrderID(orderID);
                    PhysicalStore toStore = new PhysicalStore();
                    toStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID);
                    BLL.Warehouse toWarehouse = new BLL.Warehouse();
                    toWarehouse.LoadByPrimaryKey(toStore.PhysicalStoreTypeID);
                    transferType = "Store to Store Transfer";
                    stvSentTo    = toWarehouse.Name;
                }

                if (orderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER)
                {
                    transfer.LoadByOrderID(orderID);
                    Activity fromActivity = new Activity();
                    fromActivity.LoadByPrimaryKey(transfer.FromStoreID);
                    Activity toActivity = new Activity();
                    toActivity.LoadByPrimaryKey(transfer.ToStoreID);
                    transferType   = "Account to Account Transfer";
                    transferDetail = string.Format("From: {0} To: {1}", fromActivity.FullActivityName, toActivity.FullActivityName);
                }
            }


            if (!deliveryNote)
            {
                if (InstitutionIType.IsVaccine(GeneralInfo.Current))
                {
                    return(WorkflowReportFactory.CreateModel22(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType));
                }
                var stvReport = WorkflowReportFactory.CreateSTVonHeadedPaper(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType);
                if (transferDetail != "")
                {
                    stvReport.TransferDetails.Text    = transferDetail;
                    stvReport.TransferDetails.Visible = true;
                }
                else
                {
                    stvReport.TransferDetails.Visible = false;
                }

                return(stvReport);
            }
            else
            {
                return(WorkflowReportFactory.CreateDeliveryNote(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType));
            }
        }
Esempio n. 15
0
        private void gridReceiveView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            // Bind the detail grid
            PalletLocation pl = new PalletLocation();

            try
            {
                ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);
                BLL.Receipt receiptDoc = new BLL.Receipt();
                var         rd         = new ReceiveDoc();
                rd.LoadByReceiptID(ReceiptID);

                var ps = new PhysicalStore();
                ps.LoadByPrimaryKey(rd.PhysicalStoreID);

                var w = new BLL.Warehouse();
                w.LoadByPrimaryKey(ps.PhysicalStoreTypeID);
                lblWarehouse.Text = w.Name ?? "-";

                var c = new Cluster();
                c.LoadByPrimaryKey(w.ClusterID);
                lblCluster.Text = c.Name ?? "-";



                receiptDoc.LoadByPrimaryKey(ReceiptID);
                DataTable GRNFDetail = receiptDoc.GetDetailsForGRNF();
                gridDetails.DataSource  = GRNFDetail;
                gridShortage.DataSource = receiptDoc.GetDiscrepancyForGRNF();
                int status = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["Status"]);

                var SelectGRV = gridReceiveView.GetFocusedDataRow();

                lblMode.Text       = (string)SelectGRV["ModeName"];
                lblAccount.Text    = (string)SelectGRV["AccountName"];
                lblSubAccount.Text = (string)SelectGRV["SubAccountName"];
                lblActivity.Text   = (string)SelectGRV["ActivityName"];
                lblSupplier.Text   = (string)SelectGRV["SupplierName"];
                lblPONumber.Text   = (string)SelectGRV["PONo"];

                lblType.Text   = (string)SelectGRV["ReceiptType"];
                lblStatus.Text = (string)SelectGRV["CurrentStatus"];

                var lgs = new LogReceiptStatus();
                lgs.LoadByReceiptID(ReceiptID);

                lblCalculatedDate.Text = lgs.StatusChangedDate.ToShortDateString();



                var user = new User();
                if (SelectGRV["calculatedBy"] != DBNull.Value)
                {
                    user.LoadByPrimaryKey(Convert.ToInt32(SelectGRV["calculatedBy"]));
                    lblCalculatedBy.Text = user.FullName;
                }

                else
                {
                    lblCalculatedBy.Text = "-";
                }

                lblCostConfirmedBy.Text = SelectGRV["confirmedBy"] != DBNull.Value ? SelectGRV["confirmedBy"].ToString() : "-";

                //lblGRVNumber.Text = reference;
                //lblRecivedDate.Text = ((DateTime)SelectGRV["Date"]).ToShortDateString();
                lblCostConfirmedDate.Text = SelectGRV["confirmedDate"] != DBNull.Value ? Convert.ToDateTime(SelectGRV["confirmedDate"]).ToShortDateString() : "-";


                string s = "";

                int    length = ((string)SelectGRV["STVOrInvoiceNo"]).Length;
                string grv    = (Convert.ToInt32(SelectGRV["IDPrinted"])).ToString();
                HeaderGroup.Text = "Invoice No: " + (string)SelectGRV["STVOrInvoiceNo"] + s.PadRight(240 - length) + "GRV No: " + grv;



                //ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);
                //ds = new DataSet();
                //DataTable dvMaster = pl.GetDetailsOfByReceiptID(ReceiptID);
                //dvMaster.TableName = "Master";
                //ds.Tables.Add(dvMaster);
                //gridDetails.DataSource = ds.Tables[dvMaster.TableName];



                //var receipt = new BLL.Receipt();
                //receipt.LoadByPrimaryKey(ReceiptID);
                //int receiptTypeID = receipt.ReceiptTypeID;



                if (currentMode == Modes.GRVPrinting)
                {
                    if (status != ReceiptConfirmationStatus.Constants.PRICE_CONFIRMED)
                    {
                        gridDetails.Enabled = false;

                        btnConfirm.Enabled = false;
                        btnPrint.Enabled   = false;
                        btnReturn.Enabled  = false;
                    }
                    else
                    {
                        gridDetails.Enabled = true;
                        btnConfirm.Enabled  = true;
                        btnPrint.Enabled    = true;
                        btnReturn.Enabled   = true;
                    }
                }
            }

            catch
            {
                gridDetails.DataSource  = null;
                gridShortage.DataSource = null;
            }
        }
        private void gridReceiveView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            // Bind the detail grid
            PalletLocation pl = new PalletLocation();
            if (e != null && e.PrevFocusedRowHandle < -1)
                return;

            try
            {
                DataRow dr = gridReceiveView.GetFocusedDataRow();

                if (dr == null)
                    return;

                ReceiptID = Convert.ToInt32(dr["ReceiptID"]);
                BLL.Receipt receiptDoc = new BLL.Receipt();
                receiptDoc.LoadByPrimaryKey(ReceiptID);

                DataTable GRNFDetail = receiptDoc.GetDetailsForGRNF();

                if (GRNFDetail.Rows.Count > 0)
                {
                    //var store = new Store();
                    //store.
                    BLL.PO order = new BLL.PO();
                    //var Mode = new Mode();
                    //Mode.LoadByPrimaryKey(order.ModeID);
                    //lblMode.Text = Mode.TypeName;
                    HeaderSection.Text = GRNFDetail.Rows[0]["PONumber"].ToString();

                    lblRecieveStatus.Text = dr["recieveStatus"].ToString();
                    lblReceiptNo.Text = dr["ReceiptNo"].ToString();
                    lblRecievedBy.Text = dr["ReceivedBy"].ToString();
                    lblRecievedDate.Text = Convert.ToDateTime(dr["Date"]).ToShortDateString();
                    lblReciveType.Text = (dr["ReceiveType"]).ToString();
                    lblWayBill.Text = (dr["WayBillNo"]).ToString()!="" ? dr["WayBillNo"].ToString() : "-";
                    lblTransferVoucherNo.Text = (dr["transferNo"]).ToString() != "" ? dr["transferNo"].ToString() : "-";

                    var warehouse = new BLL.Warehouse();
                    warehouse.LoadByPrimaryKey(receiptDoc.WarehouseID);
                    lblWarehouse.Text = warehouse.Name;
                    lblSupplier.Text = dr["Supplier"].ToString();

                    var cluster = new BLL.Cluster();
                    cluster.LoadByPrimaryKey(warehouse.ClusterID);
                    lblCluster.Text = cluster.Name;

                    lblDocType.Text ="";

                    lblPoType.Text = dr["POType"].ToString();
                    //var ps = new BLL.PhysicalStore();
                    //ps.LoadByPrimaryKey(order.p);
                    //lblStore.Text = ps.Name;

                    txtOrderNo.EditValue = GRNFDetail.Rows[0]["PONumber"];
                    lblPoNumber.Text = GRNFDetail.Rows[0]["PONumber"].ToString();

                    lblInvoiceNumber.Text = receiptDoc.STVOrInvoiceNo;

                    lblInsurancePolicy.Text = receiptDoc.InsurancePolicyNo!=""?receiptDoc.InsurancePolicyNo : "-";

                    var activity = new Activity();
                    activity.LoadByPrimaryKey(Convert.ToInt32(GRNFDetail.Rows[0]["ActivityID"]));

                    txtActivity.EditValue = activity.FullActivityName;
                    lblActivity.Text = activity.Name;

                    lblSubAccount.Text = activity.SubAccountName;
                    lblMode.Text = activity.ModeName;
                    lblAccount.Text = activity.AccountName;

                    gridDetails.DataSource = GRNFDetail;
                }

                if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
                {
                    gridShortage.DataSource = receiptDoc.GetDiscrepancyForGRNF();
                }

            }

            catch
            {
                gridDetails.DataSource = null;
            }
        }