private void LogTransfer_Load(object sender, EventArgs e) { var stor = new Stores(); stor.GetActiveStores(); // lkFromStore.ItemIndex = 0; storeBindingSource.DataSource = stor.DefaultView; var itemunit = new ItemUnit(); var units = itemunit.GetAllUnits(); unitBindingSource.DataSource = units.DefaultView; // bind the supplier lookup for the grid. var unitcolumn = ((GridView)gridControl1.MainView).Columns[4]; switch (VisibilitySetting.HandleUnits) { case 1: unitcolumn.Visible = false; break; case 2: unitcolumn.Visible = true; break; default: unitcolumn.Visible = true; break; } lkToStore.Properties.DataSource = stor.DefaultView; lkToStore.ItemIndex = 0; // bind the current dates try { var dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.Nodes[0].FirstNode); if (dr == null) return; var rec = new Transfer(); if (dr["ParentID"] == DBNull.Value) { // int yr = ((dtCurrent.Month > 10) ? dtCurrent.Year : dtCurrent.Year - 1); var dt1 = new DateTime(Convert.ToInt32(dr["ID"]) - 1, 11, 1); var dt2 = new DateTime(Convert.ToInt32(dr["ID"]), 11, 1); dtRec = rec.GetTransactionByDateRange(Convert.ToInt32(lkToStore.EditValue), dt1, dt2); lblTransferedDate.Text = dr["RefNo"].ToString(); } else { dtRec = rec.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(lkToStore.EditValue), dr["Date"].ToString()); lblTransferedDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy"); } gridControl1.DataSource = dtRec; } catch (Exception ex) { } }
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(); } } }
private void GeneralReport_Load(object sender, EventArgs e) { Stores stor = new Stores(); DataTable dtStor = stor.GetActiveStores(); DataRow rowStore = dtStor.NewRow(); rowStore["ID"] = "0"; rowStore["StoreName"] = "All"; dtStor.Rows.InsertAt(rowStore, 0); cboStores.Properties.DataSource = dtStor; cboStores.ItemIndex = 0; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; dtCurrent = ConvertDate.DateConverter(dtDate.Text); cboYear.Properties.DataSource = Items.AllYears(); cboYear.EditValue = dtCurrent.Year; GeneratCostChartForAllStores(); }
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); }
/// <summary> /// Load all the stores and put them in the combo box /// Set the logged in user name in the issued by text box. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void IssuingForm_Load(object sender, EventArgs e) { var unitcolumn = ((GridView)gridItemsChoice.MainView).Columns[4]; var unitid = ((GridView)issueGrid.MainView).Columns[14]; var unitcolumn1 = ((GridView)issueGrid.MainView).Columns[2]; var duamc = ((GridView)issueGrid.MainView).Columns[8]; var mrdusoh = ((GridView)issueGrid.MainView).Columns[6]; var recommendedqty = ((GridView)issueGrid.MainView).Columns[9]; var requestedqty = ((GridView)issueGrid.MainView).Columns[12]; var qtyperpack = ((GridView)issueGrid.MainView).Columns[11]; var unitcolumn3 = ((GridView)gridItemsChoice.MainView).Columns[14]; switch (VisibilitySetting.HandleUnits) { case 3: unitcolumn.Visible = false; unitcolumn1.Visible = false; unitid.Visible = true; qtyperpack.Visible = true; mrdusoh.Visible = true; duamc.Visible = true; recommendedqty.Visible = true; duamc.Visible = true; requestedqty.Visible = false; unitcolumn3.Visible = true; break; case 2: unitcolumn.Visible = false; unitcolumn1.Visible = false; unitid.Visible = true; qtyperpack.Visible = true; mrdusoh.Visible = false; recommendedqty.Visible = false; duamc.Visible = false; requestedqty.Visible = false; unitcolumn3.Visible = true; break; default: unitcolumn.Visible = true; unitcolumn1.Visible = true; unitid.Visible = false; qtyperpack.Visible = true; duamc.Visible = true; unitcolumn3.Visible = false; break; } PopulateCatTree(_selectedType); var stor = new Stores(); stor.GetActiveStores(); storebindingSource.DataSource = stor.DefaultView; cboStores.Properties.DataSource = storebindingSource.DataSource; cboStores.ItemIndex = 0; cboStores.Properties.DisplayMember = "StoreName"; cboStores.Properties.ValueMember = "ID"; cboStoreConf.Properties.DataSource = stor.DefaultView; lkCategories.Properties.DataSource = BLL.Type.GetAllTypes(); lkCategories.ItemIndex = 0; var unit = new ItemUnit(); var xx = unit.GetAllUnits(); UnitsbindingSource.DataSource = xx.DefaultView; var userID = MainWindow.LoggedinId; var us = new User(); us.LoadByPrimaryKey(userID); txtIssuedBy.Text = us.FullName; if (!chkExcludeStockedOut.Checked) gridItemChoiceView.ActiveFilterString = String.Format("TypeID={0}", Convert.ToInt32(lkCategories.EditValue)); }
private void ManageItems_Load(object sender, EventArgs e) { ReceivingUnits rec = new ReceivingUnits(); DataTable drRec = rec.GetAllApplicableDU(); cboIssuedTo.Properties.DataSource = drRec; cboIssuedTo.ItemIndex = -1;//.SelectedIndex = -1; cboIssuedTo.Text = @"Select Issue Location"; Stores stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; cboStores.ItemIndex = 0; }
private void ManageItems_Load(object sender, EventArgs e) { lkCommodityTypes.Properties.DataSource = BLL.Type.GetAllTypes(); lkCommodityTypes.ItemIndex = 0; PopulateCatTree(); ReceivingUnits recUnits = new ReceivingUnits(); recUnits.GetActiveDispensaries(); recId = new int[recUnits.RowCount]; int i = 0; if (lstItem.Columns.Count <= 2) { foreach (DataRowView dv in recUnits.DefaultView) { lstItem.Columns.Add(dv["Name"].ToString()); recId[i] = Convert.ToInt32(dv["ID"]); i++; } } Stores stor = new Stores(); stor.GetActiveStores(); cboStores.DataSource = stor.DefaultView; }
/// <summary> /// Prepare all lookups /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ManageItems_Load(object sender, EventArgs e) { var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; cboStores.ItemIndex = 0; var rec = new DisposalReasons(); var dtDis = rec.GetAvailableReasons(); cboReasons.Properties.DataSource = dtDis.DefaultView; reasonBindingSource.DataSource = dtDis.DefaultView; // cboReasons.ItemIndex = 0; var itemunit = new ItemUnit(); var units = itemunit.GetAllUnits(); unitbindingSource.DataSource = units.DefaultView; var unitcolumn = ((GridView)gridAdjustments.MainView).Columns[10]; switch (VisibilitySetting.HandleUnits) { case 1: unitcolumn.Visible = false; break; case 2: unitcolumn.Visible = true; break; default: unitcolumn.Visible = true; break; } try { //CALENDAR: var dtDate = new CalendarLib.DateTimePickerEx { CustomFormat = "MM/dd/yyyy", Value = DateTime.Now }; var dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.Nodes[0].FirstNode); if (dr == null) return; var disp = new Disposal(); if (dr["ParentID"] == DBNull.Value) { var dt1 = new DateTime(Convert.ToInt32(dr["ID"]) - 1, 11, 1); var dt2 = new DateTime(Convert.ToInt32(dr["ID"]), 11, 1); dtRec = disp.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue),dt1,dt2); lblAdjDate.Text = dr["RefNo"].ToString(); } else { dtRec = disp.GetDocumentByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue), dr["Date"].ToString()); lblAdjDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy"); } gridAdjustments.DataSource = dtRec; } catch (Exception ex) { } }
/// <summary> /// Loads the form and loads the lookups and the grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ManageItems_Load(object sender, EventArgs e) { //CALENDAR: PopulateCatTree(_selectedType); lkCommodityTypes.Properties.DataSource = BLL.Type.GetAllTypes(); lkCommodityTypes.ItemIndex = 0; Stores stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; cboStores.EditValue = 0; string[] arr = new string[] {"All", "Stock Out", "Below EOP", "Near EOP", "Normal", "Over Stocked"}; cboIssuedTo.Properties.DataSource = arr; DataTable dtMonths = new DataTable(); dtMonths.Columns.Add("Value"); dtMonths.Columns.Add("Month"); dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCur = ConvertDate.DateConverter(dtDate.Text); int currentMont = _dtCur.Month; //int year = ((currentMont < 11) ? _dtCur.Year : _dtCur.Year + 1); int year = _dtCur.Year; // this is just a try //if (currentMont >= 11) //{ // currentMont -= 11; //} DataTable dtyears = Items.AllYears(); //if (year == _dtCur.Year + 1) //{ // object[] objYear = { year }; // dtyears.Rows.Add(objYear); //} cboYear.Properties.DataSource = dtyears; cboYear.EditValue = year; if(cboYear.Properties.Columns.Count > 0) cboYear.Properties.Columns[0].Alignment = DevExpress.Utils.HorzAlignment.Near; //Programs prog = new Programs(); //DataTable dtProg = prog.GetSubPrograms(); //object[] objProg = { 0, "All Programs", "", 0, "" }; //dtProg.Rows.Add(objProg); //cboSubProgram.Properties.DataSource = dtProg; //cboSubProgram.ItemIndex = -1; //cboSubProgram.Text = "Select Program"; ReceivingUnits rec = new ReceivingUnits(); DataTable drRec = rec.GetAllApplicableDU(); cboDUnits.Properties.DataSource = drRec; cboDUnits.Properties.DisplayMember = "Name"; cboDUnits.Properties.ValueMember = "ID"; cboDUnits.EditValue = 1; this._isReady = true; PopulateGrid(); }
private void PopulateLogisticSummary() { //dtDate.Value = DateTime.Now; // dtDate.CustomFormat = "MM/dd/yyyy"; //DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); ReceivingUnits du = new ReceivingUnits(); DataTable dtDus = du.GetApplicableDUsAll(_itemId); Balance bal = new Balance(); IssueDoc iss = new IssueDoc(); Stores stor = new Stores(); stor.GetActiveStores(); DataTable dtStores = stor.DefaultView.ToTable(); DataTable dtbl = new DataTable(); dtbl.Columns.Add("StoreName"); dtbl.Columns.Add("SOH"); dtbl.Columns.Add("AMC"); dtbl.Columns.Add("Issue"); dtbl.Columns.Add("MOS"); foreach (DataRow drStr in dtStores.Rows) { int storeId = Convert.ToInt32(drStr["ID"]); Int64 soh = bal.GetSOH(_itemId, storeId, _dtCurrent.Month, _dtCurrent.Year); double amc = Builder.CalculateAverageConsumption(_itemId, storeId, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly); //bal.CalculateAMC(_itemId, storeId, _dtCurrent.Month, _dtCurrent.Year); //Builder.CalculateAverageConsumption(_itemId, storeId,dtCurrent.Subtract(TimeSpan.FromDays(180)),dtCurrent,CalculationOptions.Monthly); //bal.CalculateAMC(_itemId, storeId, _dtCurrent.Month, _dtCurrent.Year); Int64 issue = iss.GetIssuedQuantityByMonth(_itemId, storeId, _dtCurrent.Month, _dtCurrent.Year); decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); mos = Decimal.Round(mos, 1); string[] str = { drStr["StoreName"].ToString(), ((soh != 0) ? soh.ToString("#,###") : "0"), ((amc != 0) ? amc.ToString("#,###") : "0"), ((issue != 0) ? issue.ToString("#,###") : "0"), mos.ToString() }; dtbl.Rows.Add(str); } foreach (DataRow drDus in dtDus.Rows) { int duid = Convert.ToInt32(drDus["ID"]); Int64 soh = bal.GetDUSOH(_itemId, duid, _dtCurrent.Month, _dtCurrent.Year); double amc = Builder.CalculateAverageConsumption(_itemId, duid, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly);//bal.CalculateDUAMC(_itemId, duid, _dtCurrent.Month, _dtCurrent.Year, 0); Int64 issue = iss.GetDUIssueByMonth(_itemId, duid, _dtCurrent.Month, _dtCurrent.Year); decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); mos = Decimal.Round(mos, 1); string[] str = { drDus["Name"].ToString(), ((soh != 0) ? soh.ToString("#,###") : "0"), ((amc != 0) ? amc.ToString("#,###") : "0"), ((issue != 0) ? issue.ToString("#,###") : "0"), mos.ToString() }; dtbl.Rows.Add(str); } gridDispensaryView.DataSource = dtbl; }
/// <summary> /// Load the loookups /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ManageItems_Load(object sender, EventArgs e) { var unitcolumn = ((GridView) gridInventory.MainView).Columns[7]; unitcolumn.Visible = VisibilitySetting.HandleUnits != 1; var stor = new Stores(); var unit = new ItemUnit(); var allunit = unit.GetAllUnits(); unitbindingSource.DataSource = allunit.DefaultView; stor.GetActiveStores(); cboStores.DataSource = stor.DefaultView; }
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 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; }
private void GeneralReport_Load(object sender, EventArgs e) { //TabPage z = tabControl1.TabPages[2]; //tabControl1.TabPages.Remove(tabControl1.TabPages[2]); Stores stor = new Stores(); DataTable dtStor = stor.GetActiveStores(); DataRow rowStore = dtStor.NewRow(); rowStore["ID"] = "0"; rowStore["StoreName"] = "All"; dtStor.Rows.InsertAt(rowStore, 0); cboStores.DataSource = dtStor; var type = new BLL.Type(); DataTable alltypes = type.GetAllCategory(); DataRow row = alltypes.NewRow(); row["ID"] = "0"; row["Name"] = "All"; alltypes.Rows.InsertAt(row, 0); lkCategory.Properties.DataSource = alltypes; lkCategory.Properties.DisplayMember = "Name"; lkCategory.Properties.ValueMember = "ID"; lkCategory.ItemIndex = 0; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; dtCurrent = ConvertDate.DateConverter(dtDate.Text); curMont = dtCurrent.Month; // (dtCurrent.Month < 11) ? dtCurrent.Month + 2 : ((dtCurrent.Month == 11) ? 1 : 2); curYear = dtCurrent.Year;// (dtCurrent.Month < 11) ? dtCurrent.Year : dtCurrent.Year - 1; var dtyears = Items.AllYears(); cboYear.Properties.DataSource = dtyears; cboYear.EditValue = curYear; var bw = new BackgroundWorker(); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted); bw.DoWork += new DoWorkEventHandler(bw_DoWork); bw.RunWorkerAsync(); }
private void ManageItems_Load(object sender, EventArgs e) { Category cat = new Category(); SubCategory subCat = new SubCategory(); Product prod = new Product(); cat.LoadAll(); cat.Sort = "CategoryName"; lblCategory.Text = "Products By Category"; ProductTree.Nodes.Add("All0","All"); foreach (DataRowView dv in cat.DefaultView) { TreeNode nodes = new TreeNode(); nodes.Name = "cat" + dv["ID"].ToString(); nodes.Text = dv["CategoryName"].ToString() + " (" + dv["CategoryCode"].ToString() + ")"; nodes.ToolTipText = "Double Click to List"; subCat.GetSubCategory(Convert.ToInt32(dv["ID"])); subCat.Sort = "SubCategoryName"; foreach (DataRowView subDv in subCat.DefaultView) { TreeNode subNodes = new TreeNode(); subNodes.Name = "sub" + subDv["ID"].ToString(); subNodes.Text = subDv["SubCategoryName"].ToString() + " (" + subDv["SubCategoryCode"].ToString() + ")"; subNodes.ToolTipText = "Double Click to List"; nodes.Nodes.Add(subNodes); } ProductTree.Nodes[0].Nodes.Add(nodes); } ProductTree.Nodes[0].Expand(); Stores stor = new Stores(); stor.GetActiveStores(); cboStores.DataSource = stor.DefaultView; }
private void TransferForm_Load(object sender, EventArgs e) { var store = new Stores(); store.GetActiveStores(); lkFromStore.Properties.DataSource = store.DefaultView; lkCategories.Properties.DataSource = BLL.Type.GetAllTypes(); var units = new ItemUnit(); var allunits = units.GetAllUnits(); unitBindingSource.DataSource = allunits.DefaultView; lkToStore.Properties.DataSource = store.DefaultView; var unitcolumn0 = ((GridView)gridItemsChoice.MainView).Columns[7]; var unitcolumn1 = ((GridView)gridItemsChoice.MainView).Columns[2]; var unitcolumn2 = ((GridView)receivingGrid.MainView).Columns[4]; switch (VisibilitySetting.HandleUnits) { case 1: unitcolumn0.Visible = false; unitcolumn1.Visible = true; unitcolumn2.Visible = false; break; case 2: unitcolumn0.Visible = true; unitcolumn1.Visible = false; unitcolumn2.Visible = true; break; default: unitcolumn0.Visible = true; unitcolumn1.Visible = false; unitcolumn2.Visible = true; break; } lkCategories.ItemIndex = 0; lkFromStore.ItemIndex = 0; var userID = MainWindow.LoggedinId; var us = new User(); us.LoadByPrimaryKey(userID); txtApprovedBy.Text = us.FullName; // bind the current date as the datetime field dtRecDate.Value = DateTime.Now; gridItemsView.ActiveFilterString = String.Format("[ExpiryDate] > #{0}# ", DateTime.Now); }
private void DetailMos() { //dtDate.Value = DateTime.Now; //dtDate.CustomFormat = "MM/dd/yyyy"; // DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); ReceivingUnits du = new ReceivingUnits(); DataTable dtDus = du.GetApplicableDUsAll(_itemId); int col = 0; Balance bal = new Balance(); IssueDoc iss = new IssueDoc(); Stores stor = new Stores(); stor.GetActiveStores(); DataTable dtStores = stor.DefaultView.ToTable(); // lstTrendMos.Items.Clear(); foreach (DataRow drStr in dtStores.Rows) { int storeId = Convert.ToInt32(drStr["ID"]); //Int64 soh = bal.GetSOH(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //Int64 amc = bal.CalculateAMC(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //Int64 issue = iss.GetIssuedQuantityByMonth(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); //mos = Decimal.Round(mos, 1); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; decimal[] cons = new decimal[12]; for (int i = 0; i < mon.Length; i++) { int yr = (mon[i] > 10) ? _dtCurrent.Year - 1 : _dtCurrent.Year; if (!(yr == _dtCurrent.Year && mon[i] > _dtCurrent.Month && mon[i] < 11)) { Int64 soh = bal.GetSOH(_itemId, storeId, mon[i], yr); double amc = Builder.CalculateAverageConsumption(_itemId, _storeId, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly); decimal mos = ((amc != 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); cons[i] = Decimal.Round(mos, 1); } else cons[i] = 0; } string[] str = { drStr["StoreName"].ToString(), ((cons[0] != 0) ? cons[0].ToString() : "0"), ((cons[1] != 0) ? cons[1].ToString() : "0"), ((cons[2] != 0) ? cons[2].ToString() : "0"), ((cons[3] != 0) ? cons[3].ToString() : "0"), ((cons[4] != 0) ? cons[4].ToString() : "0"), ((cons[5] != 0) ? cons[5].ToString() : "0"), ((cons[6] != 0) ? cons[6].ToString() : "0"), ((cons[7] != 0) ? cons[7].ToString() : "0"), ((cons[8] != 0) ? cons[8].ToString() : "0"), ((cons[9] != 0) ? cons[9].ToString() : "0"), ((cons[10] != 0) ? cons[10].ToString() : "0"), ((cons[11] != 0) ? cons[11].ToString() : "0") }; ListViewItem lstItm = new ListViewItem(str); if (col != 0) { lstItm.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } // lstTrendMos.Items.Add(lstItm); } // lstTrendMos.Items.Add(new ListViewItem()); foreach (DataRow drDus in dtDus.Rows) { int duid = Convert.ToInt32(drDus["ID"]); //Int64 soh = bal.GetDUSOH(itemId, duid, dtCurrent.Month, dtCurrent.Year); //Int64 amc = bal.CalculateDUAMC(itemId, duid, dtCurrent.Month, dtCurrent.Year, 0); //Int64 issue = iss.GetDUIssueByMonth(itemId, duid, dtCurrent.Month, dtCurrent.Year); //decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); //mos = Decimal.Round(mos, 1); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; decimal[] cons = new decimal[12]; for (int i = 0; i < mon.Length; i++) { int yr = (mon[i] > 10) ? _dtCurrent.Year - 1 : _dtCurrent.Year; Int64 soh = bal.GetDUSOH(_itemId, duid, mon[i], yr); double amc = Builder.CalculateAverageConsumption(_itemId, duid, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly);//bal.CalculateDUAMC(_itemId, duid, mon[i], yr, 0); decimal mos = ((amc != 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); cons[i] = Decimal.Round(mos, 1); } string[] str = { drDus["Name"].ToString(), ((cons[0] != 0) ? cons[0].ToString() : "0"), ((cons[1] != 0) ? cons[1].ToString() : "0"), ((cons[2] != 0) ? cons[2].ToString() : "0"), ((cons[3] != 0) ? cons[3].ToString() : "0"), ((cons[4] != 0) ? cons[4].ToString() : "0"), ((cons[5] != 0) ? cons[5].ToString() : "0"), ((cons[6] != 0) ? cons[6].ToString() : "0"), ((cons[7] != 0) ? cons[7].ToString() : "0"), ((cons[8] != 0) ? cons[8].ToString() : "0"), ((cons[9] != 0) ? cons[9].ToString() : "0"), ((cons[10] != 0) ? cons[10].ToString() : "0"), ((cons[11] != 0) ? cons[11].ToString() : "0") }; ListViewItem lstItm = new ListViewItem(str); if (col != 0) { lstItm.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } // lstTrendMos.Items.Add(lstItm); } }
private void ManageItems_Load(object sender, EventArgs e) { PopulateCatTree(SelectedType); lkCommodityTypes.Properties.DataSource = BLL.Type.GetAllTypes(); lkCommodityTypes.ItemIndex = 0; var itemunit = new ItemUnit(); var allunits = itemunit.GetAllUnits(); unitBindingSource.DataSource = allunits.DefaultView; var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; DataTable dtMonths = new DataTable(); dtMonths.Columns.Add("Value"); dtMonths.Columns.Add("Month"); dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; dtCur = ConvertDate.DateConverter(dtDate.Text); int currentMont = dtCur.Month; int year = ((currentMont < 11) ? dtCur.Year : dtCur.Year + 1); // this is just a try if (currentMont >= 11) { currentMont -= 11; } var dtyears = Items.AllYears(); cboStores.ItemIndex = 0; cboYear.Properties.DataSource = dtyears; cboYear.EditValue = year; if (cboYear.Properties.Columns.Count > 0) cboYear.Properties.Columns[0].Alignment = DevExpress.Utils.HorzAlignment.Near; IsReady = true; PopulateGrid(); }
/// <summary> /// Load the dropdowns and the category tree /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ManageItems_Load(object sender, EventArgs e) { PopulateCatTree(_selectedType); Programs prog = new Programs(); DataTable dtProg = prog.GetSubPrograms(); object[] objProg = { 0, "All Programs", "", 0, "" }; dtProg.Rows.Add(objProg); cboSubProgram.DataSource = dtProg; cboSubProgram.SelectedIndex = -1; cboSubProgram.Text = "Select Program"; Stores stor = new Stores(); stor.GetActiveStores(); cboStores.DataSource = stor.DefaultView; }
/// <summary> /// Populate the lookups and item lists. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReceiveingForm_Load(object sender, EventArgs e) { //gridRecieveView.Columns[4].Visible = VisibilitySetting.HandleUnits; var UnitColumn = ((GridView)receivingGrid.MainView).Columns[12]; var UnitColumn1 = ((GridView)receivingGrid.MainView).Columns[5]; var UnitColumn2 = ((GridView)gridItemsChoice.MainView).Columns[4]; var qtyperpack = ((GridView)receivingGrid.MainView).Columns[3]; var buqty = ((GridView)receivingGrid.MainView).Columns[4]; switch (VisibilitySetting.HandleUnits) { case 3: UnitColumn.Visible = true; UnitColumn1.Visible = false; UnitColumn2.Visible = false; qtyperpack.Visible = false; buqty.Visible = false; break; case 2: UnitColumn.Visible = true; UnitColumn1.Visible = false; UnitColumn2.Visible = false; qtyperpack.Visible = false; buqty.Visible = false; break; case 1: UnitColumn.Visible = false; UnitColumn1.Visible = true; qtyperpack.Visible = true; UnitColumn2.Visible = true; buqty.Visible = true; break; } var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; cboStores.ItemIndex = 0; Programs prog = new Programs(); DataTable dtProg = prog.GetSubPrograms(); cboProgram.Properties.DataSource = dtProg; cboProgram.Properties.DisplayMember = "Name"; cboProgram.Properties.ValueMember = "ID"; var unit = new ItemUnit(); var units = unit.GetAllUnits(); UnitsbindingSource.DataSource = units.DefaultView; Supplier sup = new Supplier(); DataTable dtSup = new DataTable(); sup.GetActiveSuppliers(); dtSup = sup.DefaultView.ToTable(); cboSuppliers.DataSource = dtSup; cboSupplier.Properties.DataSource = sup.DefaultView; cboSuppliers.Text = "Select Supplier"; cboSuppliers.ValueMember = "ID"; cboSuppliers.DisplayMember = "CompanyName"; // Bind the grid with only active items Items itm = new Items(); //DataTable dtItem = itm.GetAllItems(1); DataTable dtItem = BLL.Items.GetActiveItemsByCommodityType(0); lkCategories.Properties.DataSource = BLL.Type.GetAllTypes(); lkCategories.ItemIndex = 0; PopulateItemList(dtItem); selectedType = radioGroup1.EditValue.ToString(); PopulateCatTree(selectedType); int userID = MainWindow.LoggedinId; User us = new User(); us.LoadByPrimaryKey(userID); txtReceivedBy.Text = us.FullName; // bind the current date as the datetime field dtRecDate.Value = DateTime.Now; }
private void GeneralReport_Load(object sender, EventArgs e) { var type = new BLL.Type(); DataTable alltypes = type.GetAllCategory(); DataRow row = alltypes.NewRow(); row["ID"] = "0"; row["Name"] = "All"; alltypes.Rows.InsertAt(row, 0); lkCategory.Properties.DataSource = alltypes; lkCategory.Properties.DisplayMember = "Name"; lkCategory.Properties.ValueMember = "ID"; lkCategory.ItemIndex = 0; Stores stor = new Stores(); stor.GetActiveStores(); DataTable dtStor = stor.DefaultView.ToTable(); DataRow rowStore = dtStor.NewRow(); rowStore["ID"] = "0"; rowStore["StoreName"] = "All"; dtStor.Rows.InsertAt(rowStore, 0); cboStores.Properties.DataSource = dtStor; cboStores.ItemIndex = 0; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; dtCurrent = ConvertDate.DateConverter(dtDate.Text); curMont = dtCurrent.Month; curYear = dtCurrent.Year; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCur = ConvertDate.DateConverter(dtDate.Text); cboYear.Properties.DataSource = Items.AllYears(); cboYear.EditValue = curYear; }
/// <summary> /// The save button should be active only when the date is Sene 30 or in the month of Hamle. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void YearEndProcess_Load(object sender, EventArgs e) { var ethDate = new EthiopianDate.EthiopianDate(); lkCommodityTypes.Properties.DataSource = BLL.Type.GetAllTypes(); lkCommodityTypes.ItemIndex = 0; btnSave.Enabled = false; var unit = new ItemUnit(); var allunits = unit.GetAllUnits(); unitBindingSource.DataSource = allunits.DefaultView; var unitcolumn = ((GridView)grdYearEnd.MainView).Columns[9]; switch (VisibilitySetting.HandleUnits) { case 1: unitcolumn.Visible = false; break; case 2: unitcolumn.Visible = true; break; default: unitcolumn.Visible = true; break; } var str = new Stores(); str.GetActiveStores(); cboStores.Properties.DataSource = str.DefaultView; cboStores.ItemIndex = 0; dtDate.CustomFormat = "MMMM dd, yyyy"; }
private void ManageItems_Load(object sender, EventArgs e) { lkCommodityTypes.Properties.DataSource = BLL.Type.GetAllTypes(); lkCommodityTypes.ItemIndex = 0; PopulateCatTree(); Stores stor = new Stores(); stor.GetActiveStores(); cboStores.DataSource = stor.DefaultView; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; dtCurrent = ConvertDate.DateConverter(dtDate.Text); Programs prog = new Programs(); DataTable dtProg = new DataTable(); dtProg = prog.GetSubPrograms(); object[] objProg = { 0, "All Programs", "", 0, "" }; dtProg.Rows.Add(objProg); cboSubProgram.DataSource = dtProg; cboSubProgram.SelectedIndex = -1; cboSubProgram.Text = "Select Program"; ReceivingUnits rec = new ReceivingUnits(); DataTable drRec = rec.GetAllApplicableDU(); cboIssuedTo.DataSource = drRec; cboIssuedTo.SelectedIndex = -1; cboIssuedTo.Text = "Select Issue Location"; int month = dtCurrent.Month; int year = ((dtCurrent.Month < 11) ? dtCurrent.Year : dtCurrent.Year + 1); DataTable dtyears = Items.AllYears(); foreach (DataRow drYears in dtyears.Rows) { int yr = Convert.ToInt32(drYears["year"]); cboYear.Items.Add(yr); } bool added = true; for (int x = 0; x < cboYear.Items.Count; x++)//to check if the current year is included or not { if (Convert.ToInt64(cboYear.Items[x]) == year) { added = false; break; } } if (added) { cboYear.Items.Add(year); } cboYear.SelectedItem = year; }
private void DetailSoh() { //CALENDAR: dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; DateTime dtCurrent = new DateTime();// Convert.ToDateTime(dtDate.Text); try { dtCurrent = Convert.ToDateTime(dtDate.Text); } catch { string dtValid = ""; string yer = ""; if (Convert.ToInt32(dtDate.Text.Substring(0, 2)) == 13) { dtValid = dtDate.Text; yer = dtValid.Substring(dtValid.Length - 4, 4); dtCurrent = Convert.ToDateTime("12/30/" + yer); } else if (Convert.ToInt32(dtDate.Text.Substring(0, 2)) == 2) { dtValid = dtDate.Text; yer = dtValid.Substring(dtValid.Length - 4, 4); dtCurrent = Convert.ToDateTime("2/28/" + yer); } } ReceivingUnits du = new ReceivingUnits(); DataTable dtDus = du.GetApplicableDUsAll(_itemId); int col = 0; Balance bal = new Balance(); IssueDoc iss = new IssueDoc(); Stores stor = new Stores(); stor.GetActiveStores(); DataTable dtStores = stor.DefaultView.ToTable(); foreach (DataRow drStr in dtStores.Rows) { int storeId = Convert.ToInt32(drStr["ID"]); //Int64 soh = bal.GetSOH(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //Int64 amc = bal.CalculateAMC(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //Int64 issue = iss.GetIssuedQuantityByMonth(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); //mos = Decimal.Round(mos, 1); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; long[] cons = new long[12]; for (int i = 0; i < mon.Length; i++) { int yr = (mon[i] > 10) ? dtCurrent.Year - 1 : dtCurrent.Year; if (!(yr == dtCurrent.Year && mon[i] > dtCurrent.Month && mon[i] < 11)) { cons[i] = bal.GetSOH(_itemId, storeId, mon[i], yr); } else cons[i] = 0; } string[] str = { drStr["StoreName"].ToString(), ((cons[0] != 0) ? cons[0].ToString("#,###") : "0"), ((cons[1] != 0) ? cons[1].ToString("#,###") : "0"), ((cons[2] != 0) ? cons[2].ToString("#,###") : "0"), ((cons[3] != 0) ? cons[3].ToString("#,###") : "0"), ((cons[4] != 0) ? cons[4].ToString("#,###") : "0"), ((cons[5] != 0) ? cons[5].ToString("#,###") : "0"), ((cons[6] != 0) ? cons[6].ToString("#,###") : "0"), ((cons[7] != 0) ? cons[7].ToString("#,###") : "0"), ((cons[8] != 0) ? cons[8].ToString("#,###") : "0"), ((cons[9] != 0) ? cons[9].ToString("#,###") : "0"), ((cons[10] != 0) ? cons[10].ToString("#,###") : "0"), ((cons[11] != 0) ? cons[11].ToString("#,###") : "0") }; ListViewItem lstItm = new ListViewItem(str); if (col != 0) { lstItm.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } //lstTrendSoh.Items.Add(lstItm); } //lstTrendSoh.Items.Add(new ListViewItem()); foreach (DataRow drDus in dtDus.Rows) { int duid = Convert.ToInt32(drDus["ID"]); //Int64 soh = bal.GetDUSOH(itemId, duid, dtCurrent.Month, dtCurrent.Year); //Int64 amc = bal.CalculateDUAMC(itemId, duid, dtCurrent.Month, dtCurrent.Year, 0); //Int64 issue = iss.GetDUIssueByMonth(itemId, duid, dtCurrent.Month, dtCurrent.Year); //decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); //mos = Decimal.Round(mos, 1); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; long[] cons = new long[12]; for (int i = 0; i < mon.Length; i++) { int yr = (mon[i] > 10) ? dtCurrent.Year - 1 : dtCurrent.Year; cons[i] = bal.GetDUSOH(_itemId, duid, mon[i], yr); } string[] str = { drDus["Name"].ToString(), ((cons[0] != 0) ? cons[0].ToString("#,###") : "0"), ((cons[1] != 0) ? cons[1].ToString("#,###") : "0"), ((cons[2] != 0) ? cons[2].ToString("#,###") : "0"), ((cons[3] != 0) ? cons[3].ToString("#,###") : "0"), ((cons[4] != 0) ? cons[4].ToString("#,###") : "0"), ((cons[5] != 0) ? cons[5].ToString("#,###") : "0"), ((cons[6] != 0) ? cons[6].ToString("#,###") : "0"), ((cons[7] != 0) ? cons[7].ToString("#,###") : "0"), ((cons[8] != 0) ? cons[8].ToString("#,###") : "0"), ((cons[9] != 0) ? cons[9].ToString("#,###") : "0"), ((cons[10] != 0) ? cons[10].ToString("#,###") : "0"), ((cons[11] != 0) ? cons[11].ToString("#,###") : "0") }; ListViewItem lstItm = new ListViewItem(str); if (col != 0) { lstItm.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } // lstTrendSoh.Items.Add(lstItm); } }
private void ManageItems_Load(object sender, EventArgs e) { DataTable dtMonths = new DataTable(); dtMonths.Columns.Add("Value"); dtMonths.Columns.Add("Month"); dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; DateTime xx = new DateTime(); try { xx = Convert.ToDateTime(dtDate.Text); } catch { string dtValid = ""; string yer = ""; if (Convert.ToInt32(dtDate.Text.Substring(0, 2)) == 13) { dtValid = dtDate.Text; yer = dtValid.Substring(dtValid.Length - 4, 4); xx = Convert.ToDateTime("12/30/" + yer); } else if (Convert.ToInt32(dtDate.Text.Substring(0, 2)) == 2) { dtValid = dtDate.Text; yer = dtValid.Substring(dtValid.Length - 4, 4); xx = Convert.ToDateTime("2/28/" + yer); } } int currentMont = xx.Month; int[] val = {11,12,1,2,3,4,5,6,7,8,9,10 }; string[] mon = { "Hamle", "Nehase", "Meskerem", "Tikemt", "Hedar", "Tahsas", "Tir", "Yekatit", "Megabit", "Miziya", "Genbot", "Sene" }; int i = 0; //currentMont; //object[] oo = {currentMont,"Current Month" }; //dtMonths.Rows.Add(oo); for (i = 0; i < val.Length; i++) { if (val[i] == currentMont) { break; } } for (int j = i; j >= 0; j--) { object[] obj = { val[j], mon[j] }; dtMonths.Rows.Add(obj); } cboMonth.DataSource = dtMonths; Stores stor = new Stores(); stor.GetActiveStores(); cboStores.DataSource = stor.DefaultView; }
private void ManageItems_Load(object sender, EventArgs e) { var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; cboStores.ItemIndex = 0; var sup = new Supplier(); var dtSup = sup.GetSuppliersWithTransaction(); cboSupplier.Properties.DataSource = dtSup; cboSupplier.ItemIndex = -1; cboSupplier.Text = "Select Supplier"; var itemunit = new ItemUnit(); var units = itemunit.GetAllUnits(); unitsbindingSource.DataSource = units.DefaultView; // bind the supplier lookup for the grid. lkEditSupplier.DataSource = dtSup; var unitcolumn = ((GridView)gridReceives.MainView).Columns[14]; switch (VisibilitySetting.HandleUnits) { case 1: unitcolumn.Visible = false; break; case 2: unitcolumn.Visible = true; break; default: unitcolumn.Visible = true; break; } // bind the current dates try { var dr = (DataRowView) lstTree.GetDataRecordByNode(lstTree.Nodes[0].FirstNode); if (dr == null) return; var rec = new ReceiveDoc(); if (dr["ParentID"] == DBNull.Value) { // int yr = ((dtCurrent.Month > 10) ? dtCurrent.Year : dtCurrent.Year - 1); var dt1 = new DateTime(Convert.ToInt32(dr["ID"]) - 1, 11, 1); var dt2 = new DateTime(Convert.ToInt32(dr["ID"]), 11, 1); dtRec = rec.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), dt1, dt2); lblRecDate.Text = dr["RefNo"].ToString(); } else { dtRec = rec.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue),dr["Date"].ToString()); lblRecDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy"); } gridReceives.DataSource = dtRec; } catch (Exception ex) { } }
/// <summary> /// Load the dropdowns and the category tree /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ManageItems_Load(object sender, EventArgs e) { PopulateCatTree(_selectedType); var type = new BLL.Type(); var alltypes = type.GetAllCategory(); lkCategory.Properties.DataSource = alltypes; lkCategory.Properties.DisplayMember = "Name"; lkCategory.Properties.ValueMember = "ID"; lkCategory.ItemIndex = 0; var stor = new Stores(); stor.GetActiveStores(); cboStores.DataSource = stor.DefaultView; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCur = ConvertDate.DateConverter(dtDate.Text); dtTo.Value = DateTime.Now; // int yearFrom = ((_dtCur.Month == 11 && _dtCur.Month == 12) ? _dtCur.Year : _dtCur.Year - 1 ); int currYear = (EthiopianDate.EthiopianDate.Now.Month < 11) ? EthiopianDate.EthiopianDate.Now.Year - 1 : EthiopianDate.EthiopianDate.Now.Year; dtFrom.Value = EthiopianDate.EthiopianDate.EthiopianToGregorian(String.Format("{0}/{1}/{2}", 1, 11, currYear)); dtFrom.CustomFormat = "MM/dd/yyyy"; DateTime dt1 = ConvertDate.DateConverter(dtFrom.Text); dtTo.CustomFormat = "MM/dd/yyyy"; DateTime dt2 = ConvertDate.DateConverter(dtTo.Text); //string dRange = "From " + dtFrom.Text + " to " + dtTo.Text; //layoutControlGroup3.Text = "Cost Report " + dRange; if (dt1 == dt2) { dt1 = ((dt1.Month == 11 || dt1.Month == 12) ? new DateTime(dt1.Year, 11, 1) : new DateTime(dt1.Year - 1, 11, 1)); //dRange = "For Year " + dt1.Year.ToString(); } this._isReady = true; txtFromDate.Text = dt1.ToShortDateString(); PopulateItemList(); }
private void ManageItems_Load(object sender, EventArgs e) { PopulateCatTree(SelectedType); lkCommodityTypes.Properties.DataSource = BLL.Type.GetAllTypes(); lkCommodityTypes.ItemIndex = 0; var itemunit = new ItemUnit(); var allunits = itemunit.GetAllUnits(); unitBindingSource.DataSource = allunits.DefaultView; var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; string[] arr = {"All", "Stock Out", "Below EOP", "Near EOP", "Normal", "Over Stocked"}; cboStatus.Properties.DataSource = arr; DataTable dtMonths = new DataTable(); dtMonths.Columns.Add("Value"); dtMonths.Columns.Add("Month"); dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; dtCur = ConvertDate.DateConverter(dtDate.Text); int currentMont = dtCur.Month; int year = ((currentMont < 11) ? dtCur.Year : dtCur.Year + 1); // this is just a try if (currentMont >= 11) { currentMont -= 11; } var dtyears = Items.AllYears(); cboYear.Properties.DataSource = dtyears; cboYear.EditValue = year; if (cboYear.Properties.Columns.Count > 0) cboYear.Properties.Columns[0].Alignment = DevExpress.Utils.HorzAlignment.Near; var prog = new Programs(); var dtProg = new DataTable(); dtProg = prog.GetSubPrograms(); object[] objProg = { 0, "All Programs", "", 0, "" }; dtProg.Rows.Add(objProg); cboSubProgram.Properties.DataSource = dtProg; cboSubProgram.ItemIndex = -1; cboSubProgram.Text = "Select Program"; var rec = new ReceivingUnits(); var drRec = rec.GetAllApplicableDU(); cboIssuedTo.Properties.DataSource = drRec; cboIssuedTo.ItemIndex = -1; cboIssuedTo.Text = "Select Issue Location"; IsReady = true; var unitcolumn = ((GridView)gridItemsChoice.MainView).Columns[15]; switch (VisibilitySetting.HandleUnits) { case 1: unitcolumn.Visible = false; break; case 2: unitcolumn.Visible = true; break; default: unitcolumn.Visible = true; break; } PopulateGrid(); }
/// <summary> /// Loads the lookups /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ManageItems_Load(object sender, EventArgs e) { PopulateCatTree(_selectedType); DataTable table = new DataTable(); table = BLL.Type.GetAllTypes(); DataRow row = table.NewRow(); row["ID"] = "0"; row["Name"] = "All"; table.Rows.InsertAt(row, 0); lkCommodityTypes.Properties.DataSource = table; // Select the very first commodity type. lkCommodityTypes.ItemIndex = 0; //DateTime xx = dtDate.Value; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCurrent = ConvertDate.DateConverter(dtDate.Text); // dtDate.Value = xx; var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; cboStores.ItemIndex = 0; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCurrent = ConvertDate.DateConverter(dtDate.Text); DataTable dtYear = Items.AllYearsReport(); DataRow roww = dtYear.NewRow(); roww["year"] = "All"; dtYear.Rows.InsertAt(roww, 0); cboYear.Properties.DataSource = dtYear; cboYear.ItemIndex = 0; }
private void RRFForm_Load(object sender, EventArgs e) { btnAutoPushToPFSA.Enabled = false; btnSendEmergencyOrder.Enabled = false; var unitcolumn = ((GridView) gridItemsChoice.MainView).Columns[2]; var unitcolumn1 = ((GridView) gridItemsChoice.MainView).Columns[13]; layoutControlItem18.Visibility =LayoutVisibility.Never; switch (VisibilitySetting.HandleUnits) { case 3: unitcolumn.Visible = false; unitcolumn1.Visible = true; break; case 2: unitcolumn.Visible = false; unitcolumn1.Visible = true; break; default: unitcolumn.Visible = true; unitcolumn1.Visible = false; break; } var unit = new ItemUnit(); var units = unit.GetAllUnits(); unitsBindingSource.DataSource = units.DefaultView; var type = new BLL.Type(); var alltypes = type.GetAllCategory(); categorybindingSource.DataSource = alltypes.DefaultView; var program = new Programs(); var programs = program.GetSubPrograms(); cboProgram.Properties.DataSource = programs; cboProgram.Properties.DisplayMember = "Name"; cboProgram.Properties.ValueMember = "ID"; var orderstatus = new PharmInventory.HelperClasses.OrderStatus(); orderbindingSource.DataSource = orderstatus.GetRRFOrders(); lkorderstatus.Properties.DataSource = orderbindingSource; lkorderstatus.Properties.ValueMember = "RecordId"; lkorderstatus.Properties.DisplayMember = "Name"; PopulateTheMonthCombos(cboFromMonth); PopulateTheMonthCombos(cboToMonth); PopulateTheYearCombo(cboFromYear); PopulateTheYearCombo(cboToYear); var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; PopulateRRFs(); WindowVisibility(false); EnableDisableStatusCheck(); var prog = new Programs(); prog.GetSubPrograms(); cboProgram.Properties.DataSource = prog.DefaultView; cboProgram.EditValue = 1000; }
/// <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 } }