protected override void Insert() { HPS.BLL.MessageBLL.BLLMessage_TFactory MessageFactory = new HPS.BLL.MessageBLL.BLLMessage_TFactory(); try { HPS.BLL.MessageBLL.BLLMessage_T MessageEntity = new HPS.BLL.MessageBLL.BLLMessage_T(); MessageEntity.MessageTitle_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageTitle_nvcTextBox.Text, TypeCode.String).ToString(); MessageEntity.Message_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Message_nvcTextBox.Text, TypeCode.String).ToString(); MessageEntity.StartDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(StartDate_nvcTextBox.Text, TypeCode.String).ToString(); MessageEntity.EndDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(EndDate_nvcTextBox.Text, TypeCode.String).ToString(); /// MessageEntity.Visited_bit = Visited_bitCheckBox.Checked; MessageEntity.RecipientUserName_nvc = (String)Hepsa.Core.Common.PersentationController.GetEntityValue(RecipientUserName_nvcComboBox.SelectedValue, TypeCode.String); MessageEntity.UserName_nvc = HPS.Common.CurrentUser.user.UserName_nvc; MessageEntity.Date_nvc = date.ConvertToPersianShortDate(); MessageEntity.Time_nvc = date.Time; MessageFactory.BeginProc(); MessageFactory.Insert(MessageEntity); MessageFactory.CommitProc(); if (DataTable != null) { DataRow dr = this.DataTable.NewRow(); dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.MessageID_bint.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.MessageID_bint, TypeCode.Int64); dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.MessageTitle_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.MessageTitle_nvc, TypeCode.String); dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Message_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Message_nvc, TypeCode.String); dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.StartDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.StartDate_nvc, TypeCode.String); dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.EndDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.EndDate_nvc, TypeCode.String); dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Visited_bit.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Visited_bit, TypeCode.Boolean); dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.RecipientUserName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.RecipientUserName_nvc, TypeCode.String); dr["RecipientUserName_nvcUserName_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(RecipientUserName_nvcComboBox); dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Date_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Date_nvc, TypeCode.String); dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Time_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Time_nvc, TypeCode.String); dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.UserName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.UserName_nvc, TypeCode.String); DataTable.Rows.Add(dr); DataTable.AcceptChanges(); } this.ClearForm(this); } catch (Exception ex) { MessageFactory.RollBackProc(); throw ex; } }
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); } }