Пример #1
0
        private void ShowButton_Click(object sender, EventArgs e)
        {
            try
            {
                string Condition            = string.Empty;
                Properties.Settings Setting = new HPS.Properties.Settings();
                Int32?SaloonID_int          = null;
                if (Setting.SaloonID_int != 0)
                {
                    SaloonID_int = Setting.SaloonID_int;
                }

                HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory LadeAssignmentFactory = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory();
                DataTable LadeAssignmentDataTable = new DataTable();

                if (string.IsNullOrEmpty(LadeAssingmentID_binttextBox.Text))
                {
                    if (!FromDatefaDatePicker.IsNull)
                    {
                        Hepsa.Core.Validation.DateRule <string> FromDateValidator = new Hepsa.Core.Validation.DateRule <string>("FromDate", "از تاریخ", null, null);
                        if (FromDateValidator.Validate(FromDatefaDatePicker.Text) == false)
                        {
                            throw new ApplicationException(FromDateValidator.Description);
                        }
                        else
                        {
                            DateTime MiladiCurrentDate = LadeAssignmentFactory.ServerDate.AddDays(-30);
                            Hepsa.Core.Common.MyDateTime OneMonthBeforeCurrentDate = new Hepsa.Core.Common.MyDateTime(MiladiCurrentDate);
                            if (FromDatefaDatePicker.Text.CompareTo(OneMonthBeforeCurrentDate.ConvertToPersianShortDate()) < 0)
                            {
                                throw new ApplicationException("تاریخ شروع نمی تواند کمتر از یک ماه اخیر باشد");
                            }
                            Condition = string.Format("Date_nvc >= '{0}'", FromDatefaDatePicker.Text);
                        }
                    }

                    if (!ToDatefaDatePicker.IsNull)
                    {
                        Hepsa.Core.Validation.DateRule <string> ToDateValidator = new Hepsa.Core.Validation.DateRule <string>("ToDate", "تا تاریخ", null, null);
                        if (ToDateValidator.Validate(ToDatefaDatePicker.Text) == false)
                        {
                            throw new ApplicationException(ToDateValidator.Description);
                        }
                        else
                        {
                            Condition = string.Format(" {0} And  Date_nvc <='{1}'", Condition, ToDatefaDatePicker.Text);
                        }
                    }


                    if (HPS.Common.CurrentUser.user.CompanyID_int != null)
                    {
                        Condition = string.Format("{0} And CompanyID_int = {1}", Condition, HPS.Common.CurrentUser.user.CompanyID_int);
                    }
                    if (this.LaderTypeID_intComboBox.SelectedIndex != -1)
                    {
                        Condition = string.Format("{0} And LaderTypeID = {1}", Condition, LaderTypeID_intComboBox.SelectedValue.ToString());
                    }

                    if (GoodID_intcomboBox.SelectedIndex != -1)
                    {
                        Condition = string.Format("{0} And GoodID_int = {1}", Condition, GoodID_intcomboBox.SelectedValue.ToString());
                    }
                    if (PortPlaceID_intcomboBox.SelectedIndex != -1)
                    {
                        Condition = string.Format("{0} And PortPlaceID_int = {1}", Condition, PortPlaceID_intcomboBox.SelectedValue.ToString());
                    }
                    if (DestinationCityID_intcomboBox.SelectedIndex != -1)
                    {
                        Condition = string.Format("{0} And CityID_int = {1} ", Condition, DestinationCityID_intcomboBox.SelectedValue.ToString());
                    }

                    if (Condition.Length > 0)
                    {
                        if (Condition.Substring(0, 4) == " And")
                        {
                            Condition = Condition.Substring(4, Condition.Length - 4);
                        }
                    }
                }
                else
                {
                    DestinationCityID_intcomboBox.SelectedIndex = -1;
                    PortPlaceID_intcomboBox.SelectedIndex       = -1;
                    GoodID_intcomboBox.SelectedIndex            = -1;
                    LaderTypeID_intComboBox.SelectedIndex       = -1;
                    this.FromDatefaDatePicker.IsNull            = true;
                    this.ToDatefaDatePicker.IsNull = true;
                    if (HPS.Common.CurrentUser.user.CompanyID_int != null)
                    {
                        Condition = string.Format("CompanyID_int = {0} and ", HPS.Common.CurrentUser.user.CompanyID_int);
                    }
                    Condition += string.Format(" LadeAssignmentID_bint = {0} ", LadeAssingmentID_binttextBox.Text);
                }

                LadeAssignmentFactory.GetAllByCondition(Condition, SaloonID_int, ref LadeAssignmentDataTable);
                this.LadeAssignmentGridView.AutoGenerateColumns = false;
                this.LadeAssignmentGridView.DataSource          = LadeAssignmentDataTable;
            }
            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }
Пример #2
0
        private void ShowButton_Click(object sender, EventArgs e)
        {
            try
            {
                string Condition            = string.Empty;
                Properties.Settings Setting = new HPS.Properties.Settings();
                Int32?SaloonID_int          = null;
                if (Setting.SaloonID_int != 0)
                {
                    SaloonID_int = Setting.SaloonID_int;
                }

                HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory LadeAssignmentFactory = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory();
                DataTable LadeAssignmentDataTable = new DataTable();

                if (string.IsNullOrEmpty(LadeAssingmentID_binttextBox.Text))
                {
                    if (!FromDatefaDatePicker.IsNull)
                    {
                        Hepsa.Core.Validation.DateRule <string> FromDateValidator = new Hepsa.Core.Validation.DateRule <string>("FromDate", "از تاریخ", null, null);
                        if (FromDateValidator.Validate(FromDatefaDatePicker.Text) == false)
                        {
                            throw new ApplicationException(FromDateValidator.Description);
                        }
                        else
                        {
                            Condition = string.Format("Date_nvc >= '{0}'", FromDatefaDatePicker.Text);
                        }
                    }

                    if (!ToDatefaDatePicker.IsNull)
                    {
                        Hepsa.Core.Validation.DateRule <string> ToDateValidator = new Hepsa.Core.Validation.DateRule <string>("ToDate", "تا تاریخ", null, null);
                        if (ToDateValidator.Validate(ToDatefaDatePicker.Text) == false)
                        {
                            throw new ApplicationException(ToDateValidator.Description);
                        }
                        else
                        {
                            Condition = string.Format(" {0} And  Date_nvc <='{1}'", Condition, ToDatefaDatePicker.Text);
                        }
                    }


                    if (this.CompanyID_intComboBox.SelectedIndex != -1)
                    {
                        Condition = string.Format("{0} And CompanyID_int = {1}", Condition, CompanyID_intComboBox.SelectedValue.ToString());
                    }
                    if (this.LaderTypeID_intComboBox.SelectedIndex != -1)
                    {
                        Condition = string.Format("{0} And LaderTypeID = {1}", Condition, LaderTypeID_intComboBox.SelectedValue.ToString());
                    }

                    if (GoodID_intcomboBox.SelectedIndex != -1)
                    {
                        Condition = string.Format("{0} And GoodID_int = {1}", Condition, GoodID_intcomboBox.SelectedValue.ToString());
                    }
                    if (PortPlaceID_intcomboBox.SelectedIndex != -1)
                    {
                        Condition = string.Format("{0} And PortPlaceID_int = {1}", Condition, PortPlaceID_intcomboBox.SelectedValue.ToString());
                    }
                    if (DestinationCityID_intcomboBox.SelectedIndex != -1)
                    {
                        Condition = string.Format("{0} And CityID_int = {1} ", Condition, DestinationCityID_intcomboBox.SelectedValue.ToString());
                    }

                    if (Condition.Length > 0)
                    {
                        if (Condition.Substring(0, 4) == " And")
                        {
                            Condition = Condition.Substring(4, Condition.Length - 4);
                        }
                    }
                }
                else
                {
                    DestinationCityID_intcomboBox.SelectedIndex = -1;
                    PortPlaceID_intcomboBox.SelectedIndex       = -1;
                    GoodID_intcomboBox.SelectedIndex            = -1;
                    LaderTypeID_intComboBox.SelectedIndex       = -1;
                    CompanyID_intComboBox.SelectedIndex         = -1;
                    this.FromDatefaDatePicker.IsNull            = true;
                    //.SelectedDateTime = FarsiLibrary.Utils.PersianDateConverter.ToGregorianDateTime(LadeAssignmentFactory.ServerJalaliDate);
                    this.ToDatefaDatePicker.IsNull = true;
                    //SelectedDateTime = FarsiLibrary.Utils.PersianDateConverter.ToGregorianDateTime(LadeAssignmentFactory.ServerJalaliDate);
                    Condition = string.Format(" LadeAssignmentID_bint = {0} ", LadeAssingmentID_binttextBox.Text);
                }

                LadeAssignmentFactory.GetAllByCondition(Condition, SaloonID_int, ref LadeAssignmentDataTable);
                this.LadeAssignmentGridView.AutoGenerateColumns = false;
                this.LadeAssignmentGridView.DataSource          = LadeAssignmentDataTable;
            }
            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }