private void bnOk_Click(object sender, System.EventArgs e) { if (((CalcAlg) this.bsCalcAlg.get_Current()) == CalcAlg.Null) { System.Windows.Forms.MessageBox.Show("Выберите методику", "Предупреждение", System.Windows.Forms.MessageBoxButtons.OK); } else if (this.dbFromDate.Value == this.dbFromDate.NullDate) { System.Windows.Forms.MessageBox.Show("Веедите дату начала действия", "Предупреждение", System.Windows.Forms.MessageBoxButtons.OK); } else if (this.dbFromDate.Value < Constants.MinDate) { System.Windows.Forms.MessageBox.Show("Дата выбранна не верно", "Предупреждение", System.Windows.Forms.MessageBoxButtons.OK); } else { this.calcAlg = (CalcAlg) this.bsCalcAlg.get_Current(); if (this.bnOk.get_Text() == "Добавить") { ServiceCalcAlg alg = new ServiceCalcAlg { ServiceId = this.m_serviceOld.Id, ServiceName = this.m_serviceOld.ShortName, CalcAlgId = this.calcAlg.Id, CalcAlgName = this.calcAlg.Name, Formula = this.calcAlg.ChargeFormulaFormula, ProcName = this.calcAlg.ChargeProcName, FromDate = this.dbFromDate.Value, Created = System.DateTime.Today }; alg.SaveChanges(); this.m_ServiceCalcAlg = alg; } else { this.m_ServiceCalcAlg.CalcAlgId = this.calcAlg.Id; this.m_ServiceCalcAlg.CalcAlgName = this.calcAlg.Name; this.m_ServiceCalcAlg.Formula = this.calcAlg.ChargeFormulaFormula; this.m_ServiceCalcAlg.ProcName = this.calcAlg.ChargeProcName; this.m_ServiceCalcAlg.FromDate = this.dbFromDate.Value; this.m_ServiceCalcAlg.SaveChanges(); } base.set_DialogResult(System.Windows.Forms.DialogResult.OK); base.Close(); } }