Esempio n. 1
0
//-----------------------Find transaction details button click event----------------------------------------------------//
        protected void BtnFind_Click(object sender, EventArgs e)
        {
            try {
                DatgridViewRefresh();
                ControlVisibleTrue();

//-----------------------------Getting the value from the date time picker----------------------------------------------//
                try
                {
                    date1 = DateTime.ParseExact(Request.Form["datepicker"], "MM/dd/yyyy", CultureInfo.InvariantCulture);
                    date2 = DateTime.ParseExact(Request.Form["datepicker2"], "MM/dd/yyyy", CultureInfo.InvariantCulture);
                }
                catch
                { }


//--------------convert date to string----------------------------------------------------------------------------------//
                string d1 = Convert.ToString(date1);
                string d2 = Convert.ToString(date2);

//---------If user wont select a date default value is "1/1/0001 12:00:00 AM".setting that to null here-----------------//
                if (d1 == "1/1/0001 12:00:00 AM" || d2 == "1/1/0001 12:00:00 AM")
                {
                    d1 = null;
                    d2 = null;
                }

//----------------------------Search based on item code & transaction dates-------------------------------------------//
//-------------Datagrid view load with transaction records of selected item within the selected dates--------------//

                //To get the item name corresponding to the item code selected
                InventoryCatalogue i  = InventoryLogic.GetInventoryDetails(TxtId.Text);
                string             d0 = date1.ToString("yyyy-MM-dd");
                string             d  = date2.ToString("yyyy-MM-dd");

                if (TxtId.Text != string.Empty && d1 != null && d2 != null)
                {
                    tList = InventoryLogic.GetTransactionByDate(date1, date2, TxtId.Text);
                    details(TxtId.Text);
                    GridViewStockCard.DataSource = tList;
                    GridViewStockCard.DataBind();

                    LblMsg.Visible = true;


                    LblMsg.Text = "*Showing transaction records of " + i.Description + " within the date range " + d0 + " and " + d;
                }

//-----------------------------Transaction records of selected item----here user not selected any dates-----------------//
                else if (TxtId.Text != string.Empty && d1 == null && d2 == null)
                {
                    string id = TxtId.Text;
                    tList = InventoryLogic.GetStockCardList(TxtId.Text);
                    details(TxtId.Text);
                    GridViewStockCard.DataSource = tList;
                    GridViewStockCard.DataBind();
                    LblMsg.Visible = true;
                    LblMsg.Text    = "*Showing transaction records of " + i.Description;
                }
//--------------------------------Transaction records within the selected date range------------------------------------//
                else if (TxtId.Text == string.Empty && d1 != null && d2 != null)
                {
                    tList = InventoryLogic.GetAllTransactionByDate(date1, date2);
                    GridViewStockCard.DataSource = tList;
                    GridViewStockCard.DataBind();
                    LblMsg.Visible = true;
                    LblMsg.Text    = "*Showing transaction records " + "within the date range " + d0 + " and " + d;
                    ControlVisibleFalse();
                }
//--------------------user don't give any input.just click search button.then this condition will fire------------------//
                else if (TxtId.Text == string.Empty && d1 == null && d2 == null)
                {
                    ControlVisibleFalse();
                    LblMsg.Visible = true;
                    LblMsg.Text    = "*Please give valid data to search in the inventory";
                }
            }
//-----------------------catch the invalid item code-----------display status message-----------------------------------//
            catch
            {
                ControlVisibleFalse();
            }
        }