private void cboStores_EditValueChanged(object sender, EventArgs e) { dtSelectedTable = null; string strStartDate; EthiopianDate.EthiopianDate startDate = EthiopianDate.EthiopianDate.Now; strStartDate = "11/1/" + (startDate.Year - 5).ToString(); string strEndDate = EthiopianDate.EthiopianDate.Now.Month.ToString() + '/' + EthiopianDate.EthiopianDate.Now.Day.ToString() + '/' + EthiopianDate.EthiopianDate.Now.Year.ToString(); var rDoc = new ReceiveDoc(); if (ckExpired.Checked && cboStores.EditValue != null && lkCategories.EditValue != null) { var dtItem = rDoc.GetRecievedItemsWithBalanceForStore(Convert.ToInt32(cboStores.EditValue), (int)lkCategories.EditValue, strStartDate, strEndDate); PopulateItemList(dtItem); gridItemChoiceView.ActiveFilterString = String.Format("[ExpiryDate] < #{0}# and [TypeID]={1}", DateTime.Now, (int)lkCategories.EditValue); } if (!ckExpired.Checked && cboStores.EditValue != null && lkCategories.EditValue != null) { var dtItem = rDoc.GetRecievedItemsWithBalanceForStore(Convert.ToInt32(cboStores.EditValue), (int)lkCategories.EditValue, strStartDate, strEndDate); PopulateItemList(dtItem); gridItemChoiceView.ActiveFilterString = String.Format("[ExpiryDate] > #{0}# and [TypeID]={1}", DateTime.Now, (int)lkCategories.EditValue, strStartDate, strEndDate); } }
/// <summary> /// Open the detailed information for an item when the user double clicks on the grid. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gridItemsChoice_DoubleClick(object sender, EventArgs e) { DataRow dr = gridItemChoiceView.GetFocusedDataRow(); if (dr == null) { return; } int itemId = Convert.ToInt32(dr["ID"]); dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCur = ConvertDate.DateConverter(dtDate.Text); int month = _dtCur.Month; //int year = (month < 11) ? Convert.ToInt32(cboYear.EditValue) : Convert.ToInt32(cboYear.EditValue); int year = Convert.ToInt32(cboYear.EditValue); EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(year, month, 30); //ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0); ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0);//ethioDate.FiscalYear con.ShowDialog(); }
private void LkFromStoreEditValueChanged(object sender, EventArgs e) { var rDoc = new ReceiveDoc(); if (lkFromStore.EditValue == null) { return; } string strStartDate; EthiopianDate.EthiopianDate startDate = EthiopianDate.EthiopianDate.Now; strStartDate = "11/1/" + (startDate.Year - 2).ToString(); string strEndDate = EthiopianDate.EthiopianDate.Now.Month.ToString() + '/' + EthiopianDate.EthiopianDate.Now.Day.ToString() + '/' + EthiopianDate.EthiopianDate.Now.Year.ToString(); var dtItem = rDoc.GetRecievedItemsWithBalanceForStore(Convert.ToInt32(lkFromStore.EditValue), (int)lkCategories.EditValue, strStartDate, strEndDate); PopulateItemList(dtItem); gridItemsView.ActiveFilterString = String.Format("[FullItemName] Like '{0}%' And [TypeID] = {1}", txtItemName.Text, (int)(lkCategories.EditValue ?? 0)); //var inventory = new YearEnd(); //if (inventory.IsInventoryCompleteToReceive(EthiopianDate.EthiopianDate.Now.Year-1, Convert.ToInt32(lkFromStore.EditValue)) != false) return; //XtraMessageBox.Show("Please First Finish All Inventory and come back!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // btnSave.Enabled = false; }
private void lstTree_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx { CustomFormat = "MM/dd/yyyy", Value = DateTime.Now }; DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); DataRowView dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.FocusedNode); 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; }
/// <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 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 VRF?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } SaveVRF(); var ginfo = new GeneralInfo(); ginfo.LoadAll(); var ethioDateFrom = new EthiopianDate.EthiopianDate(_fromYear, _fromMonth, 1); var vrfReport = new VRFReport { FacilityName = { Text = ginfo.HospitalName }, Period = { Text = string.Format("{0}, {1}", ethioDateFrom.GetMonthName(), ethioDateFrom.Year) }, ProgramName = { Text = cboProgram.Text }, categoryName = { Text = lkCategory.Text }, RegionZoneWoreda = { Text = ginfo.DSUpdateFrequency }, ResponsiblePerson = { Text = ginfo.HospitalContact }, TelephoneNumber = { Text = ginfo.Telephone }, MonthsToSupply = { Text = ginfo.RRFStatusUpdateFrequency }, Births = { Text = ginfo.RRFStatusFirstUpdateAfter }, SurvivingInfants = { Text = ginfo.ScmsWSUserName }, RequestDate = { Text = DateTime.Now.ToShortDateString() } }; var tbl1 = ((DataView)gridItemChoiceView.DataSource).Table; tbl1.TableName = "DataTable11"; var dtset = new DataSet(); dtset.Tables.Add(tbl1.Copy()); vrfReport.DataSource = dtset; if (Convert.ToInt32(cboProgram.EditValue) == 0 && Convert.ToInt32(lkCategory.EditValue) == 0) { vrfReport.ShowPreviewDialog(); } else if (Convert.ToInt32(lkCategory.EditValue) != 0) { vrfReport.FilterString = String.Format("ProgramID={0} and TypeID ={1}", Convert.ToInt32(cboProgram.EditValue), Convert.ToInt32(lkCategory.EditValue)); vrfReport.ShowPreviewDialog(); } else { vrfReport.FilterString = String.Format("ProgramID={0}", Convert.ToInt32(cboProgram.EditValue)); vrfReport.ShowPreviewDialog(); } }
/// <summary> /// //ChangedDate: /// </summary> /// <param name="storeId"></param> /// <param name="itemId"></param> /// <param name="year"></param> /// <returns></returns> public DataTable GetTransactionByItemId(int storeId, int itemId, int year) { this.FlushData(); EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(year, 1, 1); DateTime startOfFiscalYear = ethioDate.StartOfFiscalYear.ToGregorianDate(); DateTime endOfFiscalYear = ethioDate.EndOfFiscalYear.ToGregorianDate(); //this.LoadFromRawSql(String.Format("SELECT *,ROW_NUMBER() OVER (ORDER BY Date DESC) as RowNo FROM IssueDoc id join vwGetAllItems vw on id.ItemID = vw.ID WHERE StoreId = {0} AND ItemID ={1} AND ((YEAR(Date)={2} AND Month(Date) < 11) OR (Year(Date) = {3} AND Month(Date) > 10)) ORDER BY Date DESC", storeId, itemId, year, year - 1)); this.LoadFromRawSql(String.Format("SELECT *,ROW_NUMBER() OVER (ORDER BY EurDate DESC) as RowNo FROM IssueDoc id join vwGetAllItems vw on id.ItemID = vw.ID WHERE StoreId = {0} AND ItemID ={1} AND (EurDate between '{2}' and '{3}') ORDER BY Date DESC", storeId, itemId, startOfFiscalYear, endOfFiscalYear)); return(this.DataTable); }
/// <summary> /// //ChangedDate: /// </summary> /// <param name="storeId"></param> /// <param name="itemId"></param> /// <param name="year"></param> /// <returns></returns> public DataTable GetTransactionByItemId(int storeId, int itemId, int year) { this.FlushData(); EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(year, 1, 1); DateTime startOfFiscalYear = ethioDate.StartOfFiscalYear.ToGregorianDate(); DateTime endOfFiscalYear = ethioDate.EndOfFiscalYear.ToGregorianDate(); //this.LoadFromRawSql(String.Format("SELECT * FROM Disposal WHERE StoreId = {0} AND ItemId = {1} AND ((Year(Date) = {2} AND Month(Date) < 11) OR (Year(Date) = {3} AND Month(Date) > 10)) ORDER BY Date", storeId, itemId,year,year-1)); this.LoadFromRawSql( String.Format( "SELECT * FROM Disposal WHERE StoreId = {0} AND ItemId = {1} AND (EurDate between '{2}' and '{3}') ORDER BY Date", storeId, itemId, startOfFiscalYear, endOfFiscalYear)); return(this.DataTable); }
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 = 1; WindowVisibility(true); Cursor = Cursors.Default; }
/// <summary> /// Open the detailed information for an item when the user double clicks on the grid. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gridItemsChoice_DoubleClick(object sender, EventArgs e) { DataRow dr = gridItemChoiceView.GetFocusedDataRow(); if (dr == null) { return; } int itemId = Convert.ToInt32(dr["ID"]); dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCur = ConvertDate.DateConverter(dtDate.Text); int month = Convert.ToInt32(cboMonth.EditValue); //int year = (month < 11) ? Convert.ToInt32(cboYear.EditValue) : Convert.ToInt32(cboYear.EditValue); int year = Convert.ToInt32(cboYear.EditValue); var ethioDate = new EthiopianDate.EthiopianDate(year, month, 30); switch (VisibilitySetting.HandleUnits) { case 2: { unitID = Convert.ToInt32(dr["UnitID"]); var con1 = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0, unitID); //ethioDate.FiscalYear con1.ShowDialog(); } break; case 3: { unitID = Convert.ToInt32(dr["UnitID"]); var con1 = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0, unitID); //ethioDate.FiscalYear con1.ShowDialog(); } break; default: { //ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0); ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0); //ethioDate.FiscalYear con.ShowDialog(); } break; } }
private void lkAccount_EditValueChanged(object sender, EventArgs e) { var ed = new EthiopianDate.EthiopianDate(); if (lkFiscalYear.EditValue != null && lkAccount.EditValue != null) { FiscalYear fYear = new FiscalYear(); fYear.LoadByPrimaryKey(Convert.ToInt32(lkFiscalYear.EditValue)); //TODO: this has to be re-implemented. cutOffNumberReport = new CutOffNumberReport(CurrentContext.LoggedInUserName); cutOffNumberReport.DataSource = ReceiveDoc.GetCutOffNumber(Convert.ToInt32(lkFiscalYear.EditValue), Convert.ToInt32(lkAccount.EditValue)); cutOffNumberReport.xrMonth.Text = string.Format("{0}", ed.GetMonthName()); cutOffNumberReport.xrAccount.Text = string.Format("{0}", lkAccount.Text); cutOffNumberReport.xrYear.Text = string.Format("{0}", fYear.Name ); printControl1.PrintingSystem = cutOffNumberReport.PrintingSystem; cutOffNumberReport.CreateDocument(); } }
private void lkAccount_EditValueChanged(object sender, EventArgs e) { var ed = new EthiopianDate.EthiopianDate(); if (lkFiscalYear.EditValue != null && lkAccount.EditValue != null) { FiscalYear fYear = new FiscalYear(); fYear.LoadByPrimaryKey(Convert.ToInt32(lkFiscalYear.EditValue)); //TODO: this has to be re-implemented. cutOffNumberReport = new CutOffNumberReport(CurrentContext.LoggedInUserName); cutOffNumberReport.DataSource = ReceiveDoc.GetCutOffNumber(Convert.ToInt32(lkFiscalYear.EditValue), Convert.ToInt32(lkAccount.EditValue)); cutOffNumberReport.xrMonth.Text = string.Format("{0}", ed.GetMonthName()); cutOffNumberReport.xrAccount.Text = string.Format("{0}", lkAccount.Text); cutOffNumberReport.xrYear.Text = string.Format("{0}", fYear.Name); printControl1.PrintingSystem = cutOffNumberReport.PrintingSystem; cutOffNumberReport.CreateDocument(); } }
public DataTable GetAllTransaction(int itemId, int storeId, int fiscalYear) { this.FlushData(); EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(fiscalYear, 1, 1); DateTime startOfFiscalYear = ethioDate.StartOfFiscalYear.ToGregorianDate().AddDays(-1); DateTime endOfFiscalYear = ethioDate.EndOfFiscalYear.ToGregorianDate(); //int yr = (month < 11) ? year - 1 : year; //DateTime dt1 = new DateTime(yr, 11, 1); //DateTime dt2 = new DateTime(year, month, DateTime.DaysInMonth(year, month)); //this.LoadFromRawSql(String.Format("select ID,BatchNo,Cost,Date,RefNo,Quantity,ItemID,StoreID,1 AS Transact from ReceiveDoc where ItemID = {0} AND StoreID = {1} AND ( Date between '{2}' AND '{3}') union select ID,BatchNo,Cost,Date,RefNo,Quantity,ItemID,StoreID,0 AS Transact from IssueDoc where ItemID = {0} AND StoreID = {1} AND ( Date between '{2}' AND '{3}') Order by Date ASC, Transact DESC", itemId, storeId, dt1.ToString(), dt2.ToString())); string query = String.Format( "select ID,BatchNo,Cost,Date,RefNo,Quantity,ItemID,StoreID,1 AS Transact from ReceiveDoc where ItemID = {0} AND StoreID = {1} AND ( EurDate between '{2}' AND '{3}') union select ID,BatchNo,Cost,Date,RefNo,Quantity,ItemID,StoreID,0 AS Transact from IssueDoc where ItemID = {0} AND StoreID = {1} AND ( EurDate between '{2}' AND '{3}') Order by Date ASC, Transact DESC", itemId, storeId, startOfFiscalYear, endOfFiscalYear); this.LoadFromRawSql(query); return(this.DataTable); }
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> /// //ChangedDate: /// </summary> /// <param name="storeId"></param> /// <param name="itemId"></param> /// <param name="year"></param> /// <returns></returns> public DataTable GetTransactionByItemId(int storeId,int itemId,int year) { this.FlushData(); EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(year, 1, 1); DateTime startOfFiscalYear = ethioDate.StartOfFiscalYear.ToGregorianDate(); DateTime endOfFiscalYear = ethioDate.EndOfFiscalYear.ToGregorianDate(); //this.LoadFromRawSql(String.Format("SELECT *,ROW_NUMBER() OVER (ORDER BY Date DESC) as RowNo FROM IssueDoc id join vwGetAllItems vw on id.ItemID = vw.ID WHERE StoreId = {0} AND ItemID ={1} AND ((YEAR(Date)={2} AND Month(Date) < 11) OR (Year(Date) = {3} AND Month(Date) > 10)) ORDER BY Date DESC", storeId, itemId, year, year - 1)); this.LoadFromRawSql(String.Format("SELECT *,ROW_NUMBER() OVER (ORDER BY EurDate DESC) as RowNo FROM IssueDoc id join vwGetAllItems vw on id.ItemID = vw.ID WHERE StoreId = {0} AND ItemID ={1} AND (EurDate between '{2}' and '{3}') ORDER BY Date DESC", storeId, itemId, startOfFiscalYear, endOfFiscalYear)); return this.DataTable; }
/* private void GenerateBinCard() { ReceiveDoc rec = new ReceiveDoc(); IssueDoc iss = new IssueDoc(); Disposal dis = new Disposal(); DisposalReasons res = new DisposalReasons(); Balance bal = new Balance(); GeneralInfo info = new GeneralInfo(); YearEnd yEnd = new YearEnd(); Items itm = new Items(); info.LoadAll(); year = Convert.ToInt32(cboYear.SelectedItem); DataTable dtRec = rec.GetAllTransaction(itemId,storeId,dtCurrent.Month,year); DataTable dtIss = iss.GetTransactionByItemId(storeId, itemId, year); DataTable dtDis = dis.GetTransactionByItemId(storeId, itemId, year); Int64[] cStockout = { 0, 0, 0 }; Int64[] cOverStock = { 0, 0, 0 }; Int64[] cNearStockOut = { 0, 0, 0 }; Int64[] cBelowMin = { 0, 0, 0 }; //DateTime dtThree = dtCurrent.AddMonths(3); DataTable dtbin = new DataTable(); string[] col = { "Date", "Ref. No", "Receive", "Issue", "Unit Price", "Balance", "Batch No", "Expiry Date","To / From"}; foreach (string str in col) { dtbin.Columns.Add(str); } int i = 0; Int64 bBalance = 0; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; dtCurrent = ConvertDate.DateConverter(dtDate.Text); bBalance = yEnd.GetBBalance(year, storeId, itemId,dtCurrent.Month); Int64 balanceAmount = bBalance; Int64 mincon = 0; Int64 maxcon = 0; double eopcon = 0; DateTime dtT = new DateTime(); string balanceAm = ""; txtBBalance.Text = bBalance.ToString(); string ddDate = ""; string batNo = ""; foreach (DataRow dvRec in dtRec.Rows) { i++; if (Convert.ToInt32(dvRec["Transact"]) == 1) { rec.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); balanceAmount = balanceAmount + Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(rec.ItemID); if (itm.NeedExpiryBatch) { ddDate = rec.ExpDate.ToString("MMM dd,yyyy"); batNo = rec.BatchNo; } Supplier sup = new Supplier(); sup.LoadByPrimaryKey(rec.SupplierID); object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), "", Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm, batNo, ddDate, sup.CompanyName}; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); //int monb = (dtT.Month < 11) ? dtT.Month + 2 : ((dtT.Month == 11) ? 1 : 2); //int yer = (dtT.Month < 11) ? dtT.Year : dtT.Year - 1; Int64 bBal = bal.GetSOH(itemId, storeId, dtT.Month, dtT.Year); Int64 bAmc = bal.CalculateAMC(itemId, storeId, dtT.Month, dtT.Year); mincon = bAmc * info.Min; maxcon = bAmc * info.Max; eopcon = bAmc * info.EOP; if (balanceAmount == 0) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cStockout[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cStockout[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cStockout[2]++; } } else if (balanceAmount > maxcon) { //For Over stock if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cOverStock[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cOverStock[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cOverStock[2]++; } }//For Below min else if (balanceAmount > eopcon && balanceAmount <= mincon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cBelowMin[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cBelowMin[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cBelowMin[2]++; } } else if (balanceAmount > 0 && balanceAmount < eopcon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cNearStockOut[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cNearStockOut[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cNearStockOut[2]++; } } }else if(Convert.ToInt32(dvRec["Transact"]) == 0) { //DateTime dteIss = Convert.ToDateTime(drIss["Date"]); //DateTime dteRec = Convert.ToDateTime(dvRec["Date"]); //DateTime dTomorow = new DateTime(dtCurrent.Year, dtCurrent.Month, dtCurrent.Day + 1); //DateTime dteNextRec = (i <= dtRec.Rows.Count - 1) ? Convert.ToDateTime(dtRec.Rows[i]["Date"]) : dTomorow; iss.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); try { rec.LoadByPrimaryKey(iss.RecievDocID); } catch { rec.GetTransactionByBatch(itemId, dvRec["BatchNo"].ToString(), storeId); } ReceivingUnits recUnit = new ReceivingUnits(); recUnit.LoadByPrimaryKey(iss.ReceivingUnitID); string issuedTo = recUnit.Name; balanceAmount = balanceAmount - Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(iss.ItemID); if (itm.NeedExpiryBatch) { ddDate = ((rec.RowCount > 0) ? rec.ExpDate.ToString("MMM dd,yyyy") : ""); ; batNo = dvRec["BatchNo"].ToString(); //rec.BatchNo; } else { ddDate = ""; batNo = ""; } object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], "", Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm,batNo, ddDate,issuedTo}; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); //int monb1 = (dtT.Month < 11) ? dtT.Month + 2 : ((dtT.Month == 11) ? 1 : 2); //int yer1 = (dtT.Month < 11) ? dtT.Year : dtT.Year - 1; Int64 bBal = bal.GetSOH(itemId, storeId, dtT.Month, dtT.Year); Int64 bAmc = bal.CalculateAMC(itemId, storeId, dtT.Month, dtT.Year); mincon = bAmc * info.Min; maxcon = bAmc * info.Max; eopcon = bAmc * info.EOP; if (balanceAmount == 0) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cStockout[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cStockout[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cStockout[2]++; } } else if (balanceAmount > maxcon) { //For Over stock if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cOverStock[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cOverStock[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cOverStock[2]++; } }//For Below min else if (balanceAmount > eopcon && balanceAmount <= mincon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cBelowMin[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cBelowMin[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cBelowMin[2]++; } } else if (balanceAmount > 0 && balanceAmount < eopcon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cNearStockOut[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cNearStockOut[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cNearStockOut[2]++; } } } foreach (DataRow drDis in dtDis.Rows) { DateTime dteDis = Convert.ToDateTime(drDis["Date"]); DateTime dteRec = Convert.ToDateTime(dvRec["Date"]); res.LoadByPrimaryKey(Convert.ToInt32(drDis["ReasonId"])); rec.GetTransactionByBatch(itemId,drDis["BatchNo"].ToString(),storeId); DateTime dteNextRec = (i <= dtRec.Rows.Count - 1) ? Convert.ToDateTime(dtRec.Rows[i]["Date"]) : dtCurrent; if ((dteRec <= dteDis) && (dteDis < dteNextRec)) { if (Convert.ToBoolean(drDis["Losses"])) { balanceAmount = balanceAmount - Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; object[] objIss = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], "", Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason}; dtbin.Rows.Add(objIss); } else { balanceAmount = balanceAmount + Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; object[] objIss2 = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), "", Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason}; dtbin.Rows.Add(objIss2); } dtT = Convert.ToDateTime(dvRec["Date"]); Int64 bAmc = bal.CalculateAMC(itemId, storeId, dtT.Month, dtT.Year); mincon = bAmc * info.Min; maxcon = bAmc * info.Max; eopcon = bAmc * info.EOP; if (balanceAmount == 0) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cStockout[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cStockout[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cStockout[2]++; } } else if (balanceAmount > maxcon) { //For Over stock if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cOverStock[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cOverStock[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cOverStock[2]++; } }//For Below min else if (balanceAmount > eopcon && balanceAmount <= mincon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cBelowMin[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cBelowMin[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cBelowMin[2]++; } } else if (balanceAmount > 0 && balanceAmount < eopcon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cNearStockOut[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cNearStockOut[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cNearStockOut[2]++; } } } } } transactionGrid.DataSource = dtbin; //Stock Out lblThreeStockout.Text = cStockout[0].ToString(); lblSixStockOut.Text = (cStockout[0] + cStockout[1]).ToString(); lblTwelveStockOut.Text = (cStockout[0] + cStockout[1] + cStockout[2]).ToString(); //Over Stock lblThreeOverStock.Text = cOverStock[0].ToString(); lblSixOverStock.Text = (cOverStock[0] + cOverStock[1]).ToString(); lblTwelveOverStock.Text = (cOverStock[0] + cOverStock[1] + cOverStock[2]).ToString(); //Near eop lblThreeNearStock.Text = cNearStockOut[0].ToString(); lblSixNearStock.Text = (cNearStockOut[0] + cNearStockOut[1]).ToString(); lblTwelveNear.Text = (cNearStockOut[0] + cNearStockOut[1] + cNearStockOut[2]).ToString(); //Below Min lblThreeBelowMin.Text = cBelowMin[0].ToString(); lblSixBelowMin.Text = (cBelowMin[0] + cBelowMin[1]).ToString(); lblTwelveBelowMin.Text = (cBelowMin[0] + cBelowMin[1] + cBelowMin[2]).ToString(); } */ /// <summary> /// Generates the bin card transaction /// </summary> private void GenerateBinCard() { #region NewCode ////Get the beginning balance. //Int64 begBalance = 0; //YearEnd yearEnd = new YearEnd(); //begBalance = yearEnd.GetBeginningBalance(_storeId, _itemId); //txtBBalance.Text = begBalance.ToString(); ////Get the bin card. //Balance balance = new Balance(); //gridItemsList.DataSource = balance.GetBinCard(_storeId, _itemId); //return; #endregion #region Old Code ReceiveDoc rec = new ReceiveDoc(); IssueDoc iss = new IssueDoc(); Disposal dis = new Disposal(); DisposalReasons res = new DisposalReasons(); Balance bal = new Balance(); GeneralInfo info = new GeneralInfo(); YearEnd yEnd = new YearEnd(); Items itm = new Items(); info.LoadAll(); if (cboFiscalYear.SelectedItem == null) PopulateBinCardYearCombo(); //_year = Convert.ToInt32(cboFiscalYear.SelectedItem); _year = Convert.ToInt32(cboYear.SelectedItem); int yer = _year; //int mth = (_year > _dtCurrent.Year) ? _dtCurrent.Month : 10; int mth = _dtCurrent.Month; EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(_year, 1, 1); //if (_dtCurrent.Month < 11) //{ // yer = _year; //} //else //{ // yer = _year - 1; //} //DataTable dtRec = rec.GetAllTransaction(_itemId, _storeId, ethioDate.Month,ethioDate.Year); DataTable dtRec = rec.GetAllTransaction(_itemId, _storeId, ethioDate.FiscalYear); DataTable dtIss = iss.GetTransactionByItemId(_storeId, _itemId, ethioDate.FiscalYear); DataTable dtDis = dis.GetTransactionByItemId(_storeId, _itemId, ethioDate.FiscalYear); Int64[] cStockout = { 0, 0, 0 }; Int64[] cOverStock = { 0, 0, 0 }; Int64[] cNearStockOut = { 0, 0, 0 }; Int64[] cBelowMin = { 0, 0, 0 }; //DateTime dtThree = dtCurrent.AddMonths(3); DataTable dtbin = new DataTable(); string[] col = { "Date", "RefNo", "Receive", "Issue", "Unit Price", "Balance", "Batch No", "Expiry Date", "ToFrom" }; foreach (string str in col) { dtbin.Columns.Add(str); } int i = 0; Int64 bBalance = 0; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCurrent = ConvertDate.DateConverter(dtDate.Text); //bBalance = yEnd.GetBBalance(_year, _storeId, _itemId, _dtCurrent.Month); bBalance = yEnd.GetBBalance(_year, _storeId, _itemId); Int64 balanceAmount = bBalance; DateTime dtT = new DateTime(); string balanceAm = ""; string ddDate = ""; string batNo = ""; foreach (DataRow dvRec in dtRec.Rows) { i++; if (Convert.ToInt32(dvRec["Transact"]) == 1) { rec.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); if (dvRec["Quantity"] == DBNull.Value) { dvRec["Quantity"] = 0; } balanceAmount = balanceAmount + Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(rec.ItemID); if (itm.NeedExpiryBatch) { if (!rec.IsColumnNull("ExpDate")) { ddDate = rec.ExpDate.ToString("MMM dd,yyyy"); batNo = rec.BatchNo; } } Supplier sup = new Supplier(); sup.LoadByPrimaryKey(rec.SupplierID); object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), "", Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm, batNo, ddDate, sup.CompanyName }; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); } else if (Convert.ToInt32(dvRec["Transact"]) == 0) { iss.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); try { rec.LoadByPrimaryKey(iss.RecievDocID); } catch { rec.GetTransactionByBatch(_itemId, dvRec["BatchNo"].ToString(), _storeId); } ReceivingUnits recUnit = new ReceivingUnits(); recUnit.LoadByPrimaryKey(iss.ReceivingUnitID); string issuedTo = recUnit.Name; balanceAmount = balanceAmount - Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(iss.ItemID); if (itm.NeedExpiryBatch) { ddDate = ((rec.RowCount > 0) ? rec.ExpDate.ToString("MMM dd,yyyy") : ""); ; batNo = dvRec["BatchNo"].ToString(); //rec.BatchNo; } else { ddDate = ""; batNo = ""; } object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], "", Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm, batNo, ddDate, issuedTo }; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); } foreach (DataRow drDis in dtDis.Rows) { DateTime dteDis = Convert.ToDateTime(drDis["Date"]); DateTime dteRec = Convert.ToDateTime(dvRec["Date"]); res.LoadByPrimaryKey(Convert.ToInt32(drDis["ReasonId"])); rec.GetTransactionByBatch(_itemId, drDis["BatchNo"].ToString(), _storeId); DateTime dteNextRec = (i <= dtRec.Rows.Count - 1) ? Convert.ToDateTime(dtRec.Rows[i]["Date"]) : _dtCurrent; if ((dteRec <= dteDis) && (dteDis < dteNextRec)) { if (Convert.ToBoolean(drDis["Losses"])) { balanceAmount = balanceAmount - Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; if (rec.RowCount > 0) { object[] objIss = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], "", Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason }; dtbin.Rows.Add(objIss); } } else { balanceAmount = balanceAmount + Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; object[] objIss2 = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), "", Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason }; dtbin.Rows.Add(objIss2); } dtT = Convert.ToDateTime(dvRec["Date"]); } } } gridItemsList.DataSource = dtbin; #endregion }
private void lstTree_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx { CustomFormat = "MM/dd/yyyy", Value = DateTime.Now }; DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); DataRowView dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.FocusedNode); 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; }
private void BuildStoreInventoryList(int year, int storeId, DataTable dtItm) { string[] str = { "Item Name", "Batch No.", "Remark" }; foreach (string co in str) { dtBB.Columns.Add(co); } str = new string[] { "ItemId", "No.", "Beginning Balance", "Ending Balance(SOH)", "Physical Inventory", "ID", "RecID"};//, "Change Since Sene 30" }; foreach (string co in str) { dtBB.Columns.Add(co, typeof(int)); } int count = 1; var yProcess = new YearEnd(); var bal = new Balance(); dtDate.Value = DateTime.Now; DateTime dtCurent = new DateTime(); dtDate.CustomFormat = "MM/dd/yyyy"; dtCurent = ConvertDate.DateConverter(dtDate.Text); var recDoc = new ReceiveDoc(); int month = dtCurent.Month; //btnSave.Enabled = true; //CALENDAR: //if ((dtCurent.Month == 10 && dtCurent.Day == 30) || dtCurent.Month == 11) //{ // //btnSave.Enabled = ((!yProcess.IsInventoryComplete(year, storeId))); // btnSave.Enabled =true; // month = 10; //} //else // btnSave.Enabled = false; var yEnd = new YearEnd(); foreach (DataRow dr in dtItm.Rows)//For each item { string itemName = dr["ItemName"].ToString() + " - " + dr["DosageForm"].ToString() + " - " + dr["Strength"].ToString(); int itemID = Convert.ToInt32(dr["ID"]); bool BalanceExists = (yProcess.DoesBalanceExist(year, storeId, itemID, false)); //We don't want to display those items whose inventory has already been done. if (BalanceExists) continue; //bereket //Int64 soh = bal.GetSOH(Convert.ToInt32(dr["ID"]), storeId, month, year); Int64 soh = bal.GetSOHOptimized(Convert.ToInt32(dr["ID"]), storeId, month, year); Int64 bbal = yEnd.GetBBalance(year, storeId, Convert.ToInt32(dr["ID"]), month); yProcess.GetBalanceByItemId(year, storeId, Convert.ToInt32(dr["ID"])); Int64 BB = (yProcess.RowCount > 0) ? yProcess.BBalance : bbal; Int64 EB = ((yProcess.RowCount > 0 && yProcess.EBalance != 0) ? yProcess.EBalance : soh); //Now if the physical inventory is chosen to be default value, we set it to the ending balance of last year. string Phy = (yProcess.RowCount > 0) ? yProcess.PhysicalInventory.ToString() : (_defaultValueToPhysicalInventory ? EB.ToString() : ""); int id = (yProcess.RowCount > 0) ? yProcess.ID : 0; string remark = (yProcess.RowCount > 0) ? yProcess.Remark : ""; //object[] obj = {Convert.ToInt32(dr["ID"]),count,itemName,"",BB,((EB != 0)?EB.ToString("#,###"):"0"),Phy,remark,id,-1}; //dtBB.Rows.Add(obj); DataRowView drv = dtBB.DefaultView.AddNew(); if (yProcess.RowCount > 0) { drv["ID"] = yProcess.ID; } drv["ItemId"] = dr["ID"]; drv["No."] = count; drv["Item Name"] = itemName; drv["Beginning Balance"] = BB; drv["Ending Balance(SOH)"] = EB; if (Phy != "") { drv["Physical Inventory"] = Phy; } drv["RecID"] = -1; drv["Remark"] = remark; var ethioDate = new EthiopianDate.EthiopianDate(year, 1, 1); //drv["Change Since Sene 30"] = BLL.Balance.GetChangeAfterDate(itemID, storeId, ethioDate.EndOfFiscalYear.ToGregorianDate()); count++; //if (!BalanceExists) //{ int theLastBalance = 0; DataTable dtBatchs = recDoc.GetBatchWithValue(storeId, Convert.ToInt32(dr["ID"]), dtCurent); foreach (DataRow drBatch in dtBatchs.Rows) //For each batch { if (drBatch["QuantityLeft"] != DBNull.Value && Convert.ToInt64(drBatch["QuantityLeft"]) != 0) { drv = dtBB.DefaultView.AddNew(); drv["Item Name"] = ">>"; drv["Batch No."] = drBatch["BatchNo"]; drv["Ending Balance(SOH)"] = Convert.ToInt64(drBatch["QuantityLeft"]); //Now if the physical inventory is chosen to be default value, we set it to the ending balance of last year. if (_defaultValueToPhysicalInventory) drv["Physical Inventory"] = drBatch["QuantityLeft"].ToString(); theLastBalance += Convert.ToInt32(drBatch["QuantityLeft"]); drv["RecID"] = drBatch["ID"]; } } //} } grdYearEnd.DataSource = dtBB; dtDate.CustomFormat = "MMMM dd, yyyy"; }
/// <summary> /// Open the detailed information for an item when the user double clicks on the grid. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gridItemsChoice_DoubleClick(object sender, EventArgs e) { DataRow dr = gridItemChoiceView.GetFocusedDataRow(); if (dr == null) return; int itemId = Convert.ToInt32(dr["ID"]); dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCur = ConvertDate.DateConverter(dtDate.Text); int month = Convert.ToInt32(cboMonth.EditValue); //int year = (month < 11) ? Convert.ToInt32(cboYear.EditValue) : Convert.ToInt32(cboYear.EditValue); int year = Convert.ToInt32(cboYear.EditValue); var ethioDate = new EthiopianDate.EthiopianDate(year, month, 30); switch (VisibilitySetting.HandleUnits) { case 2: { unitID = Convert.ToInt32(dr["UnitID"]); var con1 = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0, unitID);//ethioDate.FiscalYear con1.ShowDialog(); } break; case 3: { unitID = Convert.ToInt32(dr["UnitID"]); var con1 = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0, unitID);//ethioDate.FiscalYear con1.ShowDialog(); } break; default: { //ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0); ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0); //ethioDate.FiscalYear con.ShowDialog(); } break; } }
/// <summary> /// Open the detailed information for an item when the user double clicks on the grid. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gridItemsChoice_DoubleClick(object sender, EventArgs e) { DataRow dr = gridItemChoiceView.GetFocusedDataRow(); if (dr == null) return; int itemId = Convert.ToInt32(dr["ID"]); dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCur = ConvertDate.DateConverter(dtDate.Text); int month =_dtCur.Month; //int year = (month < 11) ? Convert.ToInt32(cboYear.EditValue) : Convert.ToInt32(cboYear.EditValue); int year = Convert.ToInt32(cboYear.EditValue); EthiopianDate.EthiopianDate ethioDate=new EthiopianDate.EthiopianDate(year,month,30); //ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0); ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0);//ethioDate.FiscalYear con.ShowDialog(); }
/// <summary> /// //ChangedDate: /// </summary> /// <param name="storeId"></param> /// <param name="itemId"></param> /// <param name="year"></param> /// <returns></returns> public DataTable GetTransactionByItemId(int storeId, int itemId, int year) { this.FlushData(); EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(year, 1, 1); DateTime startOfFiscalYear = ethioDate.StartOfFiscalYear.ToGregorianDate(); DateTime endOfFiscalYear = ethioDate.EndOfFiscalYear.ToGregorianDate(); //this.LoadFromRawSql(String.Format("SELECT * FROM Disposal WHERE StoreId = {0} AND ItemId = {1} AND ((Year(Date) = {2} AND Month(Date) < 11) OR (Year(Date) = {3} AND Month(Date) > 10)) ORDER BY Date", storeId, itemId,year,year-1)); this.LoadFromRawSql( String.Format( "SELECT * FROM Disposal WHERE StoreId = {0} AND ItemId = {1} AND (EurDate between '{2}' and '{3}') ORDER BY Date", storeId, itemId, startOfFiscalYear, endOfFiscalYear)); return this.DataTable; }
public DataTable GetAllTransaction(int itemId, int storeId, int fiscalYear) { this.FlushData(); EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(fiscalYear, 1, 1); DateTime startOfFiscalYear = ethioDate.StartOfFiscalYear.ToGregorianDate().AddDays(-1); DateTime endOfFiscalYear = ethioDate.EndOfFiscalYear.ToGregorianDate(); //int yr = (month < 11) ? year - 1 : year; //DateTime dt1 = new DateTime(yr, 11, 1); //DateTime dt2 = new DateTime(year, month, DateTime.DaysInMonth(year, month)); //this.LoadFromRawSql(String.Format("select ID,BatchNo,Cost,Date,RefNo,Quantity,ItemID,StoreID,1 AS Transact from ReceiveDoc where ItemID = {0} AND StoreID = {1} AND ( Date between '{2}' AND '{3}') union select ID,BatchNo,Cost,Date,RefNo,Quantity,ItemID,StoreID,0 AS Transact from IssueDoc where ItemID = {0} AND StoreID = {1} AND ( Date between '{2}' AND '{3}') Order by Date ASC, Transact DESC", itemId, storeId, dt1.ToString(), dt2.ToString())); string query = String.Format( "select ID,BatchNo,Cost,Date,RefNo,Quantity,ItemID,StoreID,1 AS Transact from ReceiveDoc where ItemID = {0} AND StoreID = {1} AND ( EurDate between '{2}' AND '{3}') union select ID,BatchNo,Cost,Date,RefNo,Quantity,ItemID,StoreID,0 AS Transact from IssueDoc where ItemID = {0} AND StoreID = {1} AND ( EurDate between '{2}' AND '{3}') Order by Date ASC, Transact DESC", itemId, storeId, startOfFiscalYear, endOfFiscalYear); this.LoadFromRawSql(query); return this.DataTable; }
private void BuildStoreInventoryList(int year, int storeId, DataTable dtItm) { string[] str = { "Item Name", "Batch No.", "Remark" }; foreach (string co in str) { dtBB.Columns.Add(co); } str = new string[] { "ItemId", "No.", "Beginning Balance", "Ending Balance(SOH)", "Physical Inventory", "ID", "RecID" };//, "Change Since Sene 30" }; foreach (string co in str) { dtBB.Columns.Add(co, typeof(int)); } int count = 1; var yProcess = new YearEnd(); var bal = new Balance(); dtDate.Value = DateTime.Now; DateTime dtCurent = new DateTime(); dtDate.CustomFormat = "MM/dd/yyyy"; dtCurent = ConvertDate.DateConverter(dtDate.Text); var recDoc = new ReceiveDoc(); int month = dtCurent.Month; //btnSave.Enabled = true; //CALENDAR: //if ((dtCurent.Month == 10 && dtCurent.Day == 30) || dtCurent.Month == 11) //{ // //btnSave.Enabled = ((!yProcess.IsInventoryComplete(year, storeId))); // btnSave.Enabled =true; // month = 10; //} //else // btnSave.Enabled = false; var yEnd = new YearEnd(); foreach (DataRow dr in dtItm.Rows)//For each item { string itemName = dr["ItemName"].ToString() + " - " + dr["DosageForm"].ToString() + " - " + dr["Strength"].ToString(); int itemID = Convert.ToInt32(dr["ID"]); bool BalanceExists = (yProcess.DoesBalanceExist(year, storeId, itemID, false)); //We don't want to display those items whose inventory has already been done. if (BalanceExists) { continue; } //bereket //Int64 soh = bal.GetSOH(Convert.ToInt32(dr["ID"]), storeId, month, year); Int64 soh = bal.GetSOHOptimized(Convert.ToInt32(dr["ID"]), storeId, month, year); Int64 bbal = yEnd.GetBBalance(year, storeId, Convert.ToInt32(dr["ID"]), month); yProcess.GetBalanceByItemId(year, storeId, Convert.ToInt32(dr["ID"])); Int64 BB = (yProcess.RowCount > 0) ? yProcess.BBalance : bbal; Int64 EB = ((yProcess.RowCount > 0 && yProcess.EBalance != 0) ? yProcess.EBalance : soh); //Now if the physical inventory is chosen to be default value, we set it to the ending balance of last year. string Phy = (yProcess.RowCount > 0) ? yProcess.PhysicalInventory.ToString() : (_defaultValueToPhysicalInventory ? EB.ToString() : ""); int id = (yProcess.RowCount > 0) ? yProcess.ID : 0; string remark = (yProcess.RowCount > 0) ? yProcess.Remark : ""; //object[] obj = {Convert.ToInt32(dr["ID"]),count,itemName,"",BB,((EB != 0)?EB.ToString("#,###"):"0"),Phy,remark,id,-1}; //dtBB.Rows.Add(obj); DataRowView drv = dtBB.DefaultView.AddNew(); if (yProcess.RowCount > 0) { drv["ID"] = yProcess.ID; } drv["ItemId"] = dr["ID"]; drv["No."] = count; drv["Item Name"] = itemName; drv["Beginning Balance"] = BB; drv["Ending Balance(SOH)"] = EB; if (Phy != "") { drv["Physical Inventory"] = Phy; } drv["RecID"] = -1; drv["Remark"] = remark; var ethioDate = new EthiopianDate.EthiopianDate(year, 1, 1); //drv["Change Since Sene 30"] = BLL.Balance.GetChangeAfterDate(itemID, storeId, ethioDate.EndOfFiscalYear.ToGregorianDate()); count++; //if (!BalanceExists) //{ int theLastBalance = 0; DataTable dtBatchs = recDoc.GetBatchWithValue(storeId, Convert.ToInt32(dr["ID"]), dtCurent); foreach (DataRow drBatch in dtBatchs.Rows) //For each batch { if (drBatch["QuantityLeft"] != DBNull.Value && Convert.ToInt64(drBatch["QuantityLeft"]) != 0) { drv = dtBB.DefaultView.AddNew(); drv["Item Name"] = ">>"; drv["Batch No."] = drBatch["BatchNo"]; drv["Ending Balance(SOH)"] = Convert.ToInt64(drBatch["QuantityLeft"]); //Now if the physical inventory is chosen to be default value, we set it to the ending balance of last year. if (_defaultValueToPhysicalInventory) { drv["Physical Inventory"] = drBatch["QuantityLeft"].ToString(); } theLastBalance += Convert.ToInt32(drBatch["QuantityLeft"]); drv["RecID"] = drBatch["ID"]; } } //} } grdYearEnd.DataSource = dtBB; dtDate.CustomFormat = "MMMM dd, yyyy"; }