private void lstItem_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (lstItem.SelectedItems[0].Tag != null)
            {

                int month = dtCurrent.Month;
                int year = Convert.ToInt32(cboYear.SelectedItem);

                int itemId = Convert.ToInt32(lstItem.SelectedItems[0].Tag);
                ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.SelectedValue), year,8);
                con.ShowDialog();
            }
        }
        /// <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 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);

            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:
                    {
                        var con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue),
                                                                    year, 0);
                        con.ShowDialog();
                    }
                    break;
            }
        }
        /// <summary>
        /// We want to show the item detail report when the user double clicks on the grid row.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridItemChoiceView_DoubleClick(object sender, EventArgs e)
        {
            var view = sender as GridView;
            if (view == null) return;

            DataRow dr = view.GetFocusedDataRow();
            if (dr == null) return;

            dtIssueDate.Value = DateTime.Now;
            dtIssueDate.CustomFormat = "MM/dd/yyyy";
            DateTime dtCur = ConvertDate.DateConverter(dtIssueDate.Text);
            int year = ((dtCur.Month < 11) ? dtCur.Year : dtCur.Year + 1);
            dtIssueDate.CustomFormat = "MMM dd,yyyy";
            var itemId = Convert.ToInt32(dr["ID"]);

            switch (VisibilitySetting.HandleUnits)
            {
                case 1:
                    {
                        var con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0);
                        con.ShowDialog();
                    }
                    break;
                case 2:
                    {
                        var unitId = Convert.ToInt32(dr["UnitID"]);
                        var con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year,0,unitId);
                        con.ShowDialog();
                    }
                    break;
                case 3:
                    {
                        var unitId = Convert.ToInt32(dr["UnitID"]);
                        var con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0,unitId);
                        con.ShowDialog();
                    }
                    break;
            }
        }
        private void detailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GridView view = sender as GridView;
            DataRow dr = view.GetFocusedDataRow();
            if (dr != null)
            {

                dtRecDate.Value = DateTime.Now;
                dtRecDate.CustomFormat = "MM/dd/yyyy";
                DateTime dtCur = ConvertDate.DateConverter(dtRecDate.Text);
                int year = ((dtCur.Month < 11) ? dtCur.Year : dtCur.Year + 1);
                dtRecDate.CustomFormat = "MMM dd,yyyy";
                int itemId = Convert.ToInt32(dr["ID"]);
                ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0);
                con.ShowDialog();
            }
        }
 /// <summary>
 /// Opens the detailed item report for the chosen item
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void gridItemListView_DoubleClick(object sender, EventArgs e)
 {
     var view = sender as GridView;
     DataRow dr = view.GetFocusedDataRow();
     if (view != null && VisibilitySetting.HandleUnits==1)
     {
         if (dr != null)
         {
             dtDate.Value = DateTime.Now;
             dtDate.CustomFormat = "MM/dd/yyyy";
             DateTime dtCur = ConvertDate.DateConverter(dtDate.Text);
             var month = dtCur.Month;
             var year = (month < 11) ? dtCur.Year : dtCur.Year + 1;
             var itemId = Convert.ToInt32(dr["ID"]);
             var con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.SelectedValue), year, 0);
             con.ShowDialog();
         }
     }
     else if(view != null && VisibilitySetting.HandleUnits==2)
     {
         if (dr != null)
         {
             dtDate.Value = DateTime.Now;
             dtDate.CustomFormat = "MM/dd/yyyy";
             DateTime dtCur = ConvertDate.DateConverter(dtDate.Text);
             var month = dtCur.Month;
             var year = (month < 11) ? dtCur.Year : dtCur.Year + 1;
             var itemId = Convert.ToInt32(dr["ID"]);
             var con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.SelectedValue), year, 0, Convert.ToInt32(dr["ID"]));
             con.ShowDialog();
         }
     }
     else if (view != null && VisibilitySetting.HandleUnits == 3)
     {
        if (dr != null)
         {
             dtDate.Value = DateTime.Now;
             dtDate.CustomFormat = "MM/dd/yyyy";
             DateTime dtCur = ConvertDate.DateConverter(dtDate.Text);
             var month = dtCur.Month;
             var year = (month < 11) ? dtCur.Year : dtCur.Year + 1;
             var itemId = Convert.ToInt32(dr["ID"]);
             var con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.SelectedValue), year, 0, Convert.ToInt32(dr["ID"]));
             con.ShowDialog();
         }
     }
 }
        private void lstItem_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (lstItem.SelectedItems[0].Tag != null)
            {
                dtDate.Value = DateTime.Now;
                dtDate.CustomFormat = "MM/dd/yyyy";
                DateTime dtCur = ConvertDate.DateConverter(dtDate.Text);
                int month = dtCur.Month;
                int year = (cboYear.SelectedItem != null) ? Convert.ToInt32(cboYear.SelectedItem) : dtCur.Year;

                int itemId = Convert.ToInt32(lstItem.SelectedItems[0].Tag);
                ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.SelectedValue), year, 2);
                con.ShowDialog();
            }
        }
        /// <summary>
        /// Opens detailed item information form for the chosen item.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridItemListView_DoubleClick(object sender, EventArgs e)
        {
            GridView view = sender as GridView;
            if (view != null)
            {
                DataRow dr = view.GetFocusedDataRow();

                if (dr != null)
                {
                    dtDate.Value = DateTime.Now;
                    dtDate.CustomFormat = "MM/dd/yyyy";
                    DateTime dtCur = ConvertDate.DateConverter(dtDate.Text);
                    int month = dtCur.Month;
                    int year = (month < 11) ? dtCur.Year : dtCur.Year + 1;
                    int itemId = Convert.ToInt32(dr["ID"]);
                    ItemDetailReport con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), year, 0);
                    con.ShowDialog();
                }
            }
        }
        private void lstItem_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (lstItem.SelectedItems[0].Tag != null)
            {
                dtDate.Value = DateTime.Now;
                dtDate.CustomFormat = "MM/dd/yyyy";
                DateTime dtCur = new DateTime();// Convert.ToDateTime(dtDate.Text);
                try
                {
                    dtCur = 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);
                        dtCur = 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);
                        dtCur = Convert.ToDateTime("2/28/" + yer);
                    }
                }
                int month = Convert.ToInt32(cboMonth.SelectedValue);
                int year = (month < 11) ? dtCur.Year : dtCur.Year - 1;

                int itemId = Convert.ToInt32(lstItem.SelectedItems[0].Tag);
                ItemDetailReport con = new ItemDetailReport(itemId,Convert.ToInt32(cboStores.SelectedValue),year,0);
                con.ShowDialog();
            }
        }
        private void detailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var dr = gridView1.GetFocusedDataRow();

            if (dr == null) return;

            int tranId = Convert.ToInt32(dr["ID"]);

            var dtDate = new CalendarLib.DateTimePickerEx
                                                      {
                                                          Value = DateTime.Now,
                                                          CustomFormat = "MM/dd/yyyy"
                                                      };
            DateTime dtCur = ConvertDate.DateConverter(dtDate.Text);
            int itemId = Convert.ToInt32(dr["ItemID"]);
            int yr = ((dtCur.Month < 11) ? dtCur.Year : dtCur.Year + 1);
            switch (VisibilitySetting.HandleUnits)
            {
                case 1:
                    {
                        var con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), yr, 0);
                        con.ShowDialog();
                    }
                    break;
                case 2:
                    {
                        int unitId = Convert.ToInt32(dr["UnitID"]);
                        var con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), yr, 0,unitId);
                        con.ShowDialog();
                    }
                    break;
                case 3:
                    {
                        int unitId = Convert.ToInt32(dr["UnitID"]);
                        var con = new ItemDetailReport(itemId, Convert.ToInt32(cboStores.EditValue), yr, 0,unitId);
                        con.ShowDialog();
                    }
                    break;
            }
        }