public void Update(HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T businessObject, HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_TKeys businessObjectKey) { try { if (businessObject.UsedLadBillID_int == businessObjectKey.UsedLadBillID_int) { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueUsedLadBillID_int") == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } } else { if (businessObject.IsValid() == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } } _dataObject.Update(businessObject, businessObjectKey); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
protected override void Insert() { HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_TFactory UsedLadBillFactory = new HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_TFactory(); try { HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T UsedLadBillEntity = new HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T(); UsedLadBillEntity.Serial_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Serial_nvcTextBox.Text, TypeCode.String).ToString(); UsedLadBillEntity.LadBillNumber_int = (Int32)Hepsa.Core.Common.PersentationController.GetEntityValue(LadBillNumber_intNumericTextBox.NumericText, TypeCode.Int32); UsedLadBillEntity.Comment_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Comment_nvcTextBox.Text, TypeCode.String).ToString(); UsedLadBillEntity.Date_nvc = UsedLadBillFactory.ServerJalaliDate; UsedLadBillEntity.Time_nvc = UsedLadBillFactory.ServerTime; UsedLadBillEntity.UserName_nvc = HPS.Common.CurrentUser.user.UserName_nvc; UsedLadBillEntity.LadBillCreditID_int = (Int32)Hepsa.Core.Common.PersentationController.GetEntityValue(LadBillCreditKey.LadBillCreditID_int, TypeCode.Int32); UsedLadBillEntity.CompanyLadBillID_bint = (Int64?)Hepsa.Core.Common.PersentationController.GetEntityValue(_CompanyLadBillKey.CompanyLadBillID_bint, TypeCode.Int64); ////Check if number exist List <HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T> UsedLadBillList = UsedLadBillFactory.GetAllBy(HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T.UsedLadBill_TField.LadBillNumber_int, UsedLadBillEntity.LadBillNumber_int); if (UsedLadBillList.Count > 0) { throw new ApplicationException("این شماره قبلاً اختصاص داده شده است"); } string CompanyLadBilCondition = "[CompanyLadBill_T].[StartNumber_int]<=N'" + UsedLadBillEntity.LadBillNumber_int + "' and [CompanyLadBill_T].[EndNumber_int]>=N'" + UsedLadBillEntity.LadBillNumber_int + "' AND [CompanyLadBill_T].[Serial_nvc]='" + Serial_nvcTextBox.Text + "'"; HPS.BLL.CompanyLadBillBLL.BLLCompanyLadBill_TFactory CompanyLadBillFactory = new HPS.BLL.CompanyLadBillBLL.BLLCompanyLadBill_TFactory(); List <HPS.BLL.CompanyLadBillBLL.BLLCompanyLadBill_T> CompanyLadBillList = CompanyLadBillFactory.GetAllByCondition(CompanyLadBilCondition); if (CompanyLadBillList.Count == 0) { throw new ApplicationException("این شماره مابین شماره های اختصاص داده شده به شرکت نمی باشد"); } UsedLadBillFactory.BeginProc(); UsedLadBillFactory.Insert(UsedLadBillEntity); UsedLadBillFactory.CommitProc(); if (this._LadBillWithTrafficDataTable != null) { DataRow[] dr = this._LadBillWithTrafficDataTable.Select("LadBillCreditID_int=" + Convert.ToString(LadBillCreditKey.LadBillCreditID_int)); if (dr != null && dr.Length > 0) { dr[0].Delete(); this._LadBillWithTrafficDataTable.AcceptChanges(); } } LadBillNumber_intNumericTextBox.Text = string.Empty; Comment_nvcTextBox.Text = string.Empty; } catch (Exception ex) { UsedLadBillFactory.RollBackProc(); throw ex; } }
private void UsedLadBillToolStripButton_Click(object sender, EventArgs e) { try { if (this.LadBillWithTrafficGridView.CurrentRow != null && CompanyLadBillGridView.CurrentRow != null) { if (this.LadBillWithTrafficGridView.CurrentRow.Cells["LadBillCreditID_int"].Value != null && this.CompanyLadBillGridView.CurrentRow.Cells["CompanyLadBillID_bint"].Value != null) { HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T UsedLadBillEntity = new HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T(); UsedLadBillEntity.LadBillCreditID_int = (Int32)Hepsa.Core.Common.PersentationController.GetEntityValue(this.LadBillWithTrafficGridView.CurrentRow.Cells["LadBillCreditID_int"].Value, TypeCode.Int32); HPS.BLL.CompanyLadBillBLL.BLLCompanyLadBill_TKeys CompanyLadBillKey = new HPS.BLL.CompanyLadBillBLL.BLLCompanyLadBill_TKeys(); CompanyLadBillKey.CompanyLadBillID_bint = (Int64)this.CompanyLadBillGridView.CurrentRow.Cells["CompanyLadBillID_bint"].Value; ////////////// HPS.BLL.CompanyLadBillBLL.BLLCompanyLadBill_TFactory CompanyLaddBillFactory = new HPS.BLL.CompanyLadBillBLL.BLLCompanyLadBill_TFactory(); HPS.BLL.CompanyLadBillBLL.BLLCompanyLadBill_T CompanyLadBillEntity = CompanyLaddBillFactory.GetBy((HPS.BLL.CompanyLadBillBLL.BLLCompanyLadBill_TKeys)CompanyLadBillKey); HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_TFactory UsedLadBillFactory = new HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_TFactory(); string Condition = "(CompanyLadBill_T.StartNumber_int=N'" + CompanyLadBillEntity.StartNumber_int + "') AND (UsedLadBill_T.Serial_nvc =N'" + CompanyLadBillEntity.Serial_nvc + "') "; DataTable LadBillCountDataTable = new DataTable(); UsedLadBillFactory.GetCountByCondition(Condition, ref LadBillCountDataTable); int LadBillCount = 0; if (LadBillCountDataTable != null && LadBillCountDataTable.Rows.Count > 0) { LadBillCount = Convert.ToInt32(LadBillCountDataTable.Rows[0]["UsedLadbBillCount"].ToString()); } int Count = (CompanyLadBillEntity.EndNumber_int - CompanyLadBillEntity.StartNumber_int); if (!(Count - LadBillCount > 0)) { throw new ApplicationException("تعداد بارنامه های داده شده به این شرکت به اتمام رسیده است"); } else { UsedLadBillEntityForm UsedLadBill = new UsedLadBillEntityForm((DataTable)this.CompanyLadBillGridView.DataSource, (DataTable)LadBillWithTrafficGridView.DataSource, UsedLadBillEntity.LadBillCreditID_int, CompanyLadBillKey, Convert.ToString(this.LadBillWithTrafficGridView.CurrentRow.Cells["DriverName"].Value), Convert.ToString(this.LadBillWithTrafficGridView.CurrentRow.Cells["NumberPlate"].Value)); UsedLadBill.ShowDialog(); } } //LoadAllLadBill(); } else { throw new ApplicationException("اطلاع رسانی بار و اختصاص بارنامه مربوط خالی است"); } } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }
public void Insert(HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T businessObject) { try { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UsedLadBillID_int") == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } _dataObject.Insert(businessObject); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
protected override void Edit() { HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_TFactory UsedLadBillFactory = new HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_TFactory(); try { HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T UsedLadBillEntity = new HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T(); UsedLadBillEntity.Serial_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Serial_nvcTextBox.Text, TypeCode.String).ToString(); UsedLadBillEntity.LadBillNumber_int = (Int32)Hepsa.Core.Common.PersentationController.GetEntityValue(LadBillNumber_intNumericTextBox.NumericText, TypeCode.Int32); UsedLadBillEntity.Comment_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Comment_nvcTextBox.Text, TypeCode.String).ToString(); UsedLadBillEntity.Date_nvc = UsedLadBillFactory.ServerJalaliDate; UsedLadBillEntity.Time_nvc = UsedLadBillFactory.ServerTime; UsedLadBillEntity.UserName_nvc = HPS.Common.CurrentUser.user.UserName_nvc; UsedLadBillEntity.LadBillCreditID_int = (Int32)Hepsa.Core.Common.PersentationController.GetEntityValue(LadBillCreditKey.LadBillCreditID_int, TypeCode.Int64); UsedLadBillEntity.CompanyLadBillID_bint = (Int64?)Hepsa.Core.Common.PersentationController.GetEntityValue(_CompanyLadBillKey.CompanyLadBillID_bint, TypeCode.Int64); if (Hepsa.Core.Common.MessageBox.ConfirmMessage(HPS.Exceptions.ExceptionCs.EditMessage) == true) { UsedLadBillFactory.BeginProc(); UsedLadBillFactory.Update(UsedLadBillEntity, (HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_TKeys)Key); UsedLadBillFactory.CommitProc(); if (DataTable != null) { DataRow[] dr = DataTable.Select(HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T.UsedLadBill_TField.UsedLadBillID_int.ToString() + "='" + ((HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_TKeys)Key).UsedLadBillID_int.ToString() + "'"); if (dr.Length > 0) { dr[0][HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T.UsedLadBill_TField.Serial_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UsedLadBillEntity.Serial_nvc, TypeCode.String); dr[0][HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T.UsedLadBill_TField.LadBillNumber_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UsedLadBillEntity.LadBillNumber_int, TypeCode.Int32); dr[0][HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T.UsedLadBill_TField.Comment_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UsedLadBillEntity.Comment_nvc, TypeCode.String); dr[0][HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T.UsedLadBill_TField.Date_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UsedLadBillEntity.Date_nvc, TypeCode.String); dr[0][HPS.BLL.UsedLadBillBLL.BLLUsedLadBill_T.UsedLadBill_TField.Time_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(UsedLadBillEntity.Time_nvc, TypeCode.String); } DataTable.AcceptChanges(); } } } catch (Exception ex) { UsedLadBillFactory.RollBackProc(); throw ex; } }