public BankFish(Credit C)
 {
     State = States.WriteC;
     Cr = C;
     InitializeComponent();
     Btn_Edit.Enabled = Btn_Delete.Enabled = false;
 }
 public Check(Credit Cr)
 {
     State = States.WriteC;
     Cr1 = Cr;
     InitializeComponent();
     Btn_Edit.Enabled = Btn_Delete.Enabled = false;
 }
 public CardtoCard(Credit C)
 {
     State = States.WriteC;
     Cr = C;
     InitializeComponent();
     Btn_Edit.Enabled = Btn_Del.Enabled = false;
 }
 private void RegCredit()
 {
     //try
     //{
     Credit C = new Credit()
     {
         Type = "+",
         Price = utility.ConvertCommaPrice(Txt_Price.Text.Trim()),
         DateCredit = Date.GeoDate.Value,
         CreditID = utility.CreatedNewID(),
         Description = Txt_Description.Text.Trim()
     };
     C.TankhahID = Convert.ToInt32(Combo_Tankhah.SelectedValue);
     db.Credits.Add(C);
     db.SaveChanges();
     int ID = Convert.ToInt32(Combo_Tankhah.SelectedValue);
     db.Tankhahs.Single(p => p.TankhahID == ID).CreditCurrent += utility.ConvertCommaPrice(Txt_Price.Text.Trim());
     db.SaveChanges();
     utility.Show_Message(" این اعتبار با موفقیت ثبت شد", "ثبت");
     FormDefult();
     if (MessageBox.Show("آیا میخواهید اطلاعات این پرداخت ثبت شود؟", "سوال", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         Form_Payment FP = new Form_Payment(C);
         FP.ShowDialog();
     }
     //}
     //catch (DbUpdateException ex)
     //{
     //    MessageBox.Show(SqlServerErrorManagment.ShowError(ex, "تنخواه"), "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
     //}
     //catch (Exception ex)
     //{
     //    MessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
     //}
 }
 public Form_Payment(Credit C)
 {
     State = States.WriteC;
     Cr = C;
     InitializeComponent();
 }
 /// <summary>
 /// اینسرت اعتبار
 /// </summary>
 private void InsertCredit()
 {
     //try
     //{
     newCreditID = utility.CreatedNewID();
     Credit newCredit = new Credit()
     {
         CreditID = newCreditID,
         DateCredit = Convert.ToDateTime(Datepicker.GeoDate),
         TankhahID = Convert.ToInt32(CmbTankhah.SelectedValue),
         Type = "-",
         Price = _TotalPrice
     };
     db.Credits.Add(newCredit);
     db.Tankhahs.FirstOrDefault(p => p.TankhahID == SelectedTankhahID).CreditCurrent -= _TotalPrice;
     //}
     //catch (DbUpdateException ex)
     //{
     //    MessageBox.Show(SqlServerErrorManagment.ShowError(ex, "فاکتور") + "\n\n" + ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
     //}
     //catch (Exception ex)
     //{
     //    MessageBox.Show("خطا در ثبت اعتبار" + "\n\n" + ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
     //}
 }