private void lstTree_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { var dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.FocusedNode); if (dr == null) { return; } //lstTransactions.Items.Clear(); var iss = new IssueDoc(); DataTable dtRec; if (dr["ParentID"] == DBNull.Value) { EthiopianDate.EthiopianDate ethiopianDate = new EthiopianDate.EthiopianDate(Convert.ToInt32(dr["ID"]), 1, 1); dtRec = iss.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), ethiopianDate.StartOfFiscalYear.ToGregorianDate(), ethiopianDate.EndOfFiscalYear.ToGregorianDate()); string dateString = dr["RefNo"].ToString(); lblIssDate.Text = dateString; } else { //dtRec = iss.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue), dr["Date"].ToString()); dtRec = iss.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToDateTime(dr["Date"])); lblIssDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy"); } gridIssues.DataSource = dtRec; }
public Int64 GetBBalanceByUnit(int year, int storeId, int itemId, int month, int unitId) { //CALENDAR: this.FlushData(); Int64 bb = 0; //int bYear = ((month > 10) ? year : year - 1); EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(year, month, 30); int bYear = ethioDate.FiscalYear; string query = String.Format( "Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2} and UnitID={3} and (AutomaticallyEntered = 0 or AutomaticallyEntered is null) order by PhysicalInventory desc", storeId, itemId, bYear, unitId); this.LoadFromRawSql(query); if (this.DataTable.Rows.Count > 0 && this.DataTable.Rows[0]["PhysicalInventory"] != DBNull.Value) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else { this.LoadFromRawSql( String.Format( "Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2} and UnitID={3} and (AutomaticallyEntered = 0 or AutomaticallyEntered is null)", storeId, itemId, year - 1, unitId)); if (this.DataTable.Rows.Count > 0) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else if (((year + 8) > DateTime.Now.Year) || (month > 10 && (year + 8) == DateTime.Now.Year)) // to check if it is different year from current { Int64 cons = 0; IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); Disposal dis = new Disposal(); if ((year + 8) > DateTime.Now.Year) // to check if it is hamle and Nehase { year = year - 1; } month = 10; //} long RecievedQuantity = rec.GetReceivedQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); long AdjustedQuantity = dis.GetAdjustedQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); long IssuedQuantity = iss.GetIssuedQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); long LossQuantity = dis.GetLossesQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); // long BalanceQuantity = yEnd.GetBBalance(year, storeId, itemId, month); cons = (RecievedQuantity + AdjustedQuantity - IssuedQuantity - LossQuantity); //cons = (rec.GetReceivedQuantityTillMonth(itemId, storeId, month, year) + dis.GetAdjustedQuantityTillMonth(itemId, storeId, month, year) - iss.GetIssuedQuantityTillMonth(itemId, storeId, month, year) - dis.GetLossesQuantityTillMonth(itemId, storeId, month, year)); bb = cons; } } return(bb); }
public void GenerateAutomaticInventoryByUnit() { var ethDate = new EthiopianDate.EthiopianDate(); var stores = new Stores(); stores.GetActiveStores(); var rec = new ReceiveDoc(); var itm = new Items(); var yearEnd = new YearEnd(); var balance = new Balance(); if (!InventoryRequiredForHandlingUnit(false)) { return; } while (!stores.EOF) //This needs to be done for each store and for each item { //bereket //itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnit(stores.ID); itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnitOptimized(stores.ID, ethDate.Year); while (!itm.EOF) //For each item { var receivedoc = rec.GetDistinctUnitIDFromReceivedDoc(itm.ID); foreach (var dr in receivedoc.Rows.Cast <DataRow>().Where(dr => !DoesBalanceExistByUnit(ethDate.Year, itm.ID, stores.ID, true, Convert.ToInt32(dr["UnitID"])))) { //need optimization //we can exclude the already calculated items when we exclude never recieved items yearEnd.LoadByItemIDStoreAndYearAndUnit(itm.ID, stores.ID, ethDate.Year, true, Convert.ToInt32(dr["UnitID"])); if (yearEnd.RowCount > 0) { continue; } yearEnd.AddNew(); yearEnd.ItemID = itm.ID; yearEnd.StoreID = stores.ID; yearEnd.Year = ethDate.Year; //need optimization //atleast we can get the value directly by filtering using storeid and itemid rather than //selecting all items in all stores and filter it by code //yearEnd.EBalance = balance.GetSOHByUnit(itm.ID, stores.ID, ethDate.Month, ethDate.Year, Convert.ToInt32(dr["UnitID"])); yearEnd.EBalance = balance.GetSOHByUnitOptimized(itm.ID, stores.ID, ethDate.Month, ethDate.Year, Convert.ToInt32(dr["UnitID"])); yearEnd.PhysicalInventory = yearEnd.EBalance; yearEnd.AutomaticallyEntered = true; yearEnd.UnitID = Convert.ToInt32(dr["UnitID"]); yearEnd.Save(); } itm.MoveNext(); } stores.MoveNext(); } }
public void GenerateAutomaticInventory() { var ethDate = new EthiopianDate.EthiopianDate(); if (InventoryRequired(false)) { Stores stores = new Stores(); stores.GetActiveStores(); while (!stores.EOF) //This needs to be done for each store { if (!DoesBalanceExist(ethDate.Year, stores.ID, true)) //If Inventory information hasn't already been filled for this store { var itm = new Items(); //bereket //itm.ExcludeNeverReceivedItemsNoCategory(stores.ID); itm.ExcludeNeverReceivedItemsNoCategoryOptimized(stores.ID, ethDate.Year); while (!itm.EOF) //For each time { var yearEnd = new YearEnd(); var balance = new Balance(); yearEnd.LoadByItemIDStoreAndYear(itm.ID, stores.ID, ethDate.Year, true); if (yearEnd.RowCount > 0) { return; } //YearEnd.PurgeAutomaticallyEnteredInventory(itm.ID, stores.ID, ethDate.Year); yearEnd.AddNew(); yearEnd.ItemID = itm.ID; yearEnd.StoreID = stores.ID; yearEnd.Year = ethDate.Year; //bereket //yearEnd.EBalance = balance.GetSOH(itm.ID, stores.ID, 10, ethDate.Year); yearEnd.EBalance = balance.GetSOHOptimized(itm.ID, stores.ID, 10, ethDate.Year); yearEnd.PhysicalInventory = yearEnd.EBalance; yearEnd.AutomaticallyEntered = true; yearEnd.UnitID = 0; yearEnd.Save(); itm.MoveNext(); } } stores.MoveNext(); } } }
public bool InventoryRequiredForHandlingUnit(bool ignoreAutomatic) { var ethDate = new EthiopianDate.EthiopianDate(); if ((ethDate.Month == 10 && ethDate.Day == 30) || ethDate.Month == 11) { var stores = new Stores(); stores.GetActiveStores(); while (!stores.EOF) { var itm = new Items(); itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnit(stores.ID); if (!this.DoesBalanceExist(ethDate.Year, stores.ID, !ignoreAutomatic) && itm.RowCount > 0) { return(true); } stores.MoveNext(); } } return(false); }
/* public Int64 GetBBalance(int year, int storeId, int itemId) * { * this.FlushData(); * this.LoadFromRawSql(String.Format("Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2}",storeId,itemId,year)); * * Int64 bb = ( this.DataTable.Rows.Count > 0)? Convert.ToInt64(this.DataTable.Rows[0]["BBalance"]):0; * * return bb; * }*/ public double GetBBalanceAmount(int year, int storeId, int itemId, int month) { //CALENDAR: this.FlushData(); double bb = 0; EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(year, month, 30); //int bYear = ((month > 10) ? year : year - 1); int bYear = ethioDate.StartOfFiscalYear.Year; string query = String.Format("Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2}", storeId, itemId, bYear); this.LoadFromRawSql(query); if (this.DataTable.Rows.Count > 0) { bb = ((this.DataTable.Rows[0]["PhysicalInventoryPrice"].ToString() != "") ? Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventoryPrice"]) : 0); } else { string queryString = String.Format("Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2}", storeId, itemId, year - 1); this.LoadFromRawSql(queryString); if (this.DataTable.Rows.Count > 0) { bb = ((this.DataTable.Rows[0]["PhysicalInventoryPrice"].ToString() != "") ? Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventoryPrice"]) : 0); } else if (((year + 8) > DateTime.Now.Year) || (month > 10 && (year + 8) == DateTime.Now.Year)) // to check if it is different year from current { double cons = 0; IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); Disposal dis = new Disposal(); if ((year + 8) > DateTime.Now.Year) // to check if it is hamle and Nehase { year = year - 1; } month = 10; //} double ReceivedAmount = rec.GetReceivedAmountTillMonth(itemId, storeId, month, year); double AdjustedAmount = dis.GetAdjustedAmountTillMonth(itemId, storeId, month, year); double IssuedAmount = iss.GetIssuedAmountTillMonth(itemId, storeId, month, year); double LostAmount = dis.GetLossesAmountTillMonth(itemId, storeId, month, year); cons = ((ReceivedAmount + AdjustedAmount - IssuedAmount) - LostAmount); bb = cons; } } if (bb < 0) { } return(bb); //this.FlushData(); //this.LoadFromRawSql(String.Format("Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2}", storeId, itemId, year-1)); //double bb = (this.DataTable.Rows.Count > 0) ? ((this.DataTable.Rows[0]["PhysicalInventoryPrice"].ToString() != "") ? Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventoryPrice"]) : 0) : 0; //return bb; }
/// <summary> /// Populate the lookups /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ManageItems_Load(object sender, EventArgs e) { var rec = new ReceivingUnits(); DataTable drRec = rec.GetAllApplicableDU(); cboIssuedTo.Properties.DataSource = drRec; cboIssuedTo.ItemIndex = -1;//.SelectedIndex = -1; cboIssuedTo.Text = @"Select Issue Location"; var itemunit = new ItemUnit(); var units = itemunit.GetAllUnits(); unitbindingSource.DataSource = units.DefaultView; // populate the receiving unit's lookup edit var rus = new ReceivingUnits(); rus.GetActiveDispensaries(); lkEditReceivingUnis.DataSource = rus.DefaultView; var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; cboStores.ItemIndex = 0; var unitcolumn = ((GridView)gridIssues.MainView).Columns[12]; switch (VisibilitySetting.HandleUnits) { case 1: unitcolumn.Visible = false; break; case 2: unitcolumn.Visible = true; break; default: unitcolumn.Visible = true; break; } try { DataRowView dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.Nodes[0].FirstNode); if (dr == null) { return; } //lstTransactions.Items.Clear(); IssueDoc iss = new IssueDoc(); DataTable dtRec; if (dr["ParentID"] == DBNull.Value) { EthiopianDate.EthiopianDate ethiopianDate = new EthiopianDate.EthiopianDate(Convert.ToInt32(dr["ID"]), 1, 1); dtRec = iss.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), ethiopianDate.StartOfFiscalYear.ToGregorianDate(), ethiopianDate.EndOfFiscalYear.ToGregorianDate()); string dateString = dr["RefNo"].ToString(); lblIssDate.Text = dateString; } else { //dtRec = iss.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue), dr["Date"].ToString()); dtRec = iss.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToDateTime(dr["Date"])); lblIssDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy"); } gridIssues.DataSource = dtRec; } catch (Exception ex) { // do nothing } }
/// <summary> /// Populate the lookups /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ManageItems_Load(object sender, EventArgs e) { var rec = new ReceivingUnits(); DataTable drRec = rec.GetAllApplicableDU(); cboIssuedTo.Properties.DataSource = drRec; cboIssuedTo.ItemIndex = -1;//.SelectedIndex = -1; cboIssuedTo.Text = @"Select Issue Location"; var itemunit = new ItemUnit(); var units = itemunit.GetAllUnits(); unitbindingSource.DataSource = units.DefaultView; // populate the receiving unit's lookup edit var rus = new ReceivingUnits(); rus.GetActiveDispensaries(); lkEditReceivingUnis.DataSource = rus.DefaultView; var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; cboStores.ItemIndex = 0; var unitcolumn = ((GridView)gridIssues.MainView).Columns[12]; switch (VisibilitySetting.HandleUnits) { case 1: unitcolumn.Visible = false; break; case 2: unitcolumn.Visible = true; break; default: unitcolumn.Visible = true; break; } try { DataRowView dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.Nodes[0].FirstNode); if (dr == null) return; //lstTransactions.Items.Clear(); IssueDoc iss = new IssueDoc(); DataTable dtRec; if (dr["ParentID"] == DBNull.Value) { EthiopianDate.EthiopianDate ethiopianDate = new EthiopianDate.EthiopianDate(Convert.ToInt32(dr["ID"]), 1, 1); dtRec = iss.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), ethiopianDate.StartOfFiscalYear.ToGregorianDate(), ethiopianDate.EndOfFiscalYear.ToGregorianDate()); string dateString = dr["RefNo"].ToString(); lblIssDate.Text = dateString; } else { //dtRec = iss.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue), dr["Date"].ToString()); dtRec = iss.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToDateTime(dr["Date"])); lblIssDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy"); } gridIssues.DataSource = dtRec; } catch (Exception ex) { // do nothing } }
public Int64 GetBBalanceByUnit(int year, int storeId, int itemId, int month, int unitId) { //CALENDAR: this.FlushData(); Int64 bb = 0; //int bYear = ((month > 10) ? year : year - 1); EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(year, month, 30); int bYear = ethioDate.FiscalYear; string query = String.Format( "Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2} and UnitID={3} and (AutomaticallyEntered = 0 or AutomaticallyEntered is null) order by PhysicalInventory desc", storeId, itemId, bYear, unitId); this.LoadFromRawSql(query); if (this.DataTable.Rows.Count > 0 && this.DataTable.Rows[0]["PhysicalInventory"] != DBNull.Value) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else { this.LoadFromRawSql( String.Format( "Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2} and UnitID={3} and (AutomaticallyEntered = 0 or AutomaticallyEntered is null)", storeId, itemId, year - 1, unitId)); if (this.DataTable.Rows.Count > 0) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else if (((year + 8) > DateTime.Now.Year) || (month > 10 && (year + 8) == DateTime.Now.Year)) // to check if it is different year from current { Int64 cons = 0; IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); Disposal dis = new Disposal(); if ((year + 8) > DateTime.Now.Year) // to check if it is hamle and Nehase year = year - 1; month = 10; //} long RecievedQuantity = rec.GetReceivedQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); long AdjustedQuantity = dis.GetAdjustedQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); long IssuedQuantity = iss.GetIssuedQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); long LossQuantity = dis.GetLossesQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); // long BalanceQuantity = yEnd.GetBBalance(year, storeId, itemId, month); cons = (RecievedQuantity + AdjustedQuantity - IssuedQuantity - LossQuantity); //cons = (rec.GetReceivedQuantityTillMonth(itemId, storeId, month, year) + dis.GetAdjustedQuantityTillMonth(itemId, storeId, month, year) - iss.GetIssuedQuantityTillMonth(itemId, storeId, month, year) - dis.GetLossesQuantityTillMonth(itemId, storeId, month, year)); bb = cons; } } return bb; }
public bool InventoryRequiredForHandlingUnit(bool ignoreAutomatic) { var ethDate = new EthiopianDate.EthiopianDate(); if ((ethDate.Month == 10 && ethDate.Day == 30) || ethDate.Month == 11) { var stores = new Stores(); stores.GetActiveStores(); while (!stores.EOF) { var itm = new Items(); itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnit(stores.ID); if (!this.DoesBalanceExist(ethDate.Year,stores.ID, !ignoreAutomatic) && itm.RowCount > 0) { return true; } stores.MoveNext(); } } return false; }
/* public Int64 GetBBalance(int year, int storeId, int itemId) { this.FlushData(); this.LoadFromRawSql(String.Format("Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2}",storeId,itemId,year)); Int64 bb = ( this.DataTable.Rows.Count > 0)? Convert.ToInt64(this.DataTable.Rows[0]["BBalance"]):0; return bb; }*/ public double GetBBalanceAmount(int year, int storeId, int itemId, int month) { //CALENDAR: this.FlushData(); double bb = 0; EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(year, month, 30); //int bYear = ((month > 10) ? year : year - 1); int bYear = ethioDate.StartOfFiscalYear.Year; string query = String.Format("Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2}", storeId, itemId, bYear); this.LoadFromRawSql(query); if (this.DataTable.Rows.Count > 0) { bb = ((this.DataTable.Rows[0]["PhysicalInventoryPrice"].ToString() != "") ? Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventoryPrice"]) : 0); } else { string queryString = String.Format("Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2}", storeId, itemId, year - 1); this.LoadFromRawSql(queryString); if (this.DataTable.Rows.Count > 0) { bb = ((this.DataTable.Rows[0]["PhysicalInventoryPrice"].ToString() != "") ? Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventoryPrice"]) : 0); } else if (((year + 8) > DateTime.Now.Year) || (month > 10 && (year + 8) == DateTime.Now.Year)) // to check if it is different year from current { double cons = 0; IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); Disposal dis = new Disposal(); if ((year + 8) > DateTime.Now.Year) // to check if it is hamle and Nehase year = year - 1; month = 10; //} double ReceivedAmount = rec.GetReceivedAmountTillMonth(itemId, storeId, month, year); double AdjustedAmount = dis.GetAdjustedAmountTillMonth(itemId, storeId, month, year); double IssuedAmount = iss.GetIssuedAmountTillMonth(itemId, storeId, month, year); double LostAmount = dis.GetLossesAmountTillMonth(itemId, storeId, month, year); cons = ((ReceivedAmount + AdjustedAmount - IssuedAmount) - LostAmount); bb = cons; } } if (bb < 0) { } return bb; //this.FlushData(); //this.LoadFromRawSql(String.Format("Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2}", storeId, itemId, year-1)); //double bb = (this.DataTable.Rows.Count > 0) ? ((this.DataTable.Rows[0]["PhysicalInventoryPrice"].ToString() != "") ? Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventoryPrice"]) : 0) : 0; //return bb; }
public void GenerateAutomaticInventoryByUnit() { var ethDate = new EthiopianDate.EthiopianDate(); var stores = new Stores(); stores.GetActiveStores(); var rec = new ReceiveDoc(); var itm = new Items(); var yearEnd = new YearEnd(); var balance = new Balance(); if (!InventoryRequiredForHandlingUnit(false)) return; while (!stores.EOF) //This needs to be done for each store and for each item { //bereket //itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnit(stores.ID); itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnitOptimized(stores.ID, ethDate.Year); while (!itm.EOF) //For each item { var receivedoc = rec.GetDistinctUnitIDFromReceivedDoc(itm.ID); foreach (var dr in receivedoc.Rows.Cast<DataRow>().Where(dr =>!DoesBalanceExistByUnit(ethDate.Year, itm.ID, stores.ID, true,Convert.ToInt32(dr["UnitID"])))) { //need optimization //we can exclude the already calculated items when we exclude never recieved items yearEnd.LoadByItemIDStoreAndYearAndUnit(itm.ID, stores.ID, ethDate.Year, true, Convert.ToInt32(dr["UnitID"])); if (yearEnd.RowCount > 0) continue; yearEnd.AddNew(); yearEnd.ItemID = itm.ID; yearEnd.StoreID = stores.ID; yearEnd.Year = ethDate.Year; //need optimization //atleast we can get the value directly by filtering using storeid and itemid rather than //selecting all items in all stores and filter it by code //yearEnd.EBalance = balance.GetSOHByUnit(itm.ID, stores.ID, ethDate.Month, ethDate.Year, Convert.ToInt32(dr["UnitID"])); yearEnd.EBalance = balance.GetSOHByUnitOptimized(itm.ID, stores.ID, ethDate.Month, ethDate.Year, Convert.ToInt32(dr["UnitID"])); yearEnd.PhysicalInventory = yearEnd.EBalance; yearEnd.AutomaticallyEntered = true; yearEnd.UnitID = Convert.ToInt32(dr["UnitID"]); yearEnd.Save(); } itm.MoveNext(); } stores.MoveNext(); } }
private void btnNewRRF_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; var ethiopianDate = new EthiopianDate.EthiopianDate(); int currentMonth = ethiopianDate.Month; int currentYear = ethiopianDate.Year; int startingMonth = GetStartingMonth(currentMonth); int startingYear = GetStartingYear(currentMonth, currentYear); cboFromMonth.EditValue = startingMonth; cboFromYear.EditValue = startingYear; SetEndingMonthAndYear(startingMonth, startingYear); cboStores.ItemIndex = 0; WindowVisibility(true); Cursor = Cursors.Default; }
/// <summary> /// Populate the lookups /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ManageItems_Load(object sender, EventArgs e) { var usr = new User(); var userID = MainWindow.LoggedinId; usr.LoadByPrimaryKey(userID); if (usr.UserType == 1) { contextMenuStrip1.Enabled = false; } GeneralInfo gn = new GeneralInfo(); gn.LoadAll(); _priceRate = gn.IsColumnNull("PriceRate") ? 0 : Convert.ToDouble(gn.PriceRate); _usesModel = gn.IsColumnNull("UsesModel") ? false : gn.UsesModel; _printedby = usr.FullName; layoutPrintModel.Visibility = _usesModel ? DevExpress.XtraLayout.Utils.LayoutVisibility.Always : DevExpress.XtraLayout.Utils.LayoutVisibility.Never; var rec = new ReceivingUnits(); DataTable drRec = rec.GetAllApplicableDU(); //cboIssuedTo.Properties.DataSource = drRec; //cboIssuedTo.ItemIndex = -1;//.SelectedIndex = -1; //cboIssuedTo.Text = @"Select Issue Location"; var itemunit = new ItemUnit(); var units = itemunit.GetAllUnits(); unitbindingSource.DataSource = units.DefaultView; // populate the receiving unit's lookup edit var rus = new ReceivingUnits(); rus.GetActiveDispensaries(); lkEditReceivingUnis.DataSource = rus.DefaultView; //var stor = new Stores(); //stor.GetActiveStores(); UserStore ucs = new UserStore(); DataTable dt = ucs.GetUserStore(MainWindow.LoggedinId); //cboStores.Properties.DataSource = stor.DefaultView; cboStores.Properties.DataSource = dt; cboStores.ItemIndex = 0; var unitcolumn = ((GridView)gridIssues.MainView).Columns[12]; switch (VisibilitySetting.HandleUnits) { case 1: unitcolumn.Visible = false; break; case 2: unitcolumn.Visible = true; break; default: unitcolumn.Visible = true; break; } try { DataRowView dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.Nodes[0].FirstNode); if (dr == null) { return; } //lstTransactions.Items.Clear(); IssueDoc iss = new IssueDoc(); DataTable dtRec; if (dr["ParentID"] == DBNull.Value) { EthiopianDate.EthiopianDate ethiopianDate = new EthiopianDate.EthiopianDate(Convert.ToInt32(dr["ID"]), 1, 1); dtRec = iss.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), ethiopianDate.StartOfFiscalYear.ToGregorianDate(), ethiopianDate.EndOfFiscalYear.ToGregorianDate()); string dateString = dr["RefNo"].ToString(); lblIssDate.Text = dateString; } else { //dtRec = iss.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue), dr["Date"].ToString()); dtRec = iss.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToDateTime(dr["Date"])); lblIssDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy"); } gridIssues.DataSource = dtRec; grdLogIssue.ActiveFilterString = String.Format("Quantity<>0"); } catch (Exception ex) { // do nothing } grdLogIssue.Columns["InternalDrugCode"].Visible = Convert.ToBoolean(chkIntDrugCode.EditValue); }
private void btnPrint_Click(object sender, EventArgs e) { if (VisibilitySetting.HandleUnits == 3) chkCalculateInPacks.Enabled = false; chkCalculateInPacks.Checked = false; if ( XtraMessageBox.Show("Are you sure you want to save and print the RRF?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; SaveRRF(); var ginfo = new GeneralInfo(); ginfo.LoadAll(); var ethioDateFrom = new EthiopianDate.EthiopianDate(_fromYear, _fromMonth, 1); var ethioDateTo = new EthiopianDate.EthiopianDate(_toYear, _toMonth, 30); var rrfReport = new RRFReport { FacilityName = {Text = ginfo.HospitalName}, Period = { Text = string.Format("{0}, {1} - {2}, {3}", ethioDateFrom.GetMonthName(), ethioDateFrom.Year, ethioDateTo.GetMonthName(), ethioDateTo.Year) }, ProgramName = {Text = cboProgram.Text}, categoryName = {Text = lkCategory.Text} }; var tbl = ((DataView) gridItemChoiceView.DataSource).Table; tbl.TableName = "DataTable1"; var dtset = new DataSet(); dtset.Tables.Add(tbl.Copy()); rrfReport.DataSource = dtset; if (Convert.ToInt32(cboProgram.EditValue) == 0 && Convert.ToInt32(lkCategory.EditValue) == 0) { rrfReport.ShowPreviewDialog(); } else if(Convert.ToInt32(lkCategory.EditValue) != 0) { rrfReport.FilterString = String.Format("ProgramID={0} and TypeID ={1}", Convert.ToInt32(cboProgram.EditValue) ,Convert.ToInt32(lkCategory.EditValue)); rrfReport.ShowPreviewDialog(); } else { rrfReport.FilterString = String.Format("ProgramID={0}", Convert.ToInt32(cboProgram.EditValue)); rrfReport.ShowPreviewDialog(); } }
private void lstTree_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { var dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.FocusedNode); if (dr == null) return; //lstTransactions.Items.Clear(); var iss = new IssueDoc(); DataTable dtRec; if (dr["ParentID"] == DBNull.Value) { EthiopianDate.EthiopianDate ethiopianDate=new EthiopianDate.EthiopianDate(Convert.ToInt32(dr["ID"]),1,1); dtRec = iss.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), ethiopianDate.StartOfFiscalYear.ToGregorianDate(), ethiopianDate.EndOfFiscalYear.ToGregorianDate()); string dateString = dr["RefNo"].ToString(); lblIssDate.Text = dateString; } else { //dtRec = iss.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue), dr["Date"].ToString()); dtRec = iss.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToDateTime(dr["Date"])); lblIssDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy"); } gridIssues.DataSource = dtRec; }