public BankFish(Factor F)
 {
     State = States.WriteF;
     Fa = F;
     InitializeComponent();
     Btn_Edit.Enabled = Btn_Delete.Enabled = false;
 }
 public Check(Factor F)
 {
     State = States.WriteF;
     F1 = F;
     InitializeComponent();
     Btn_Edit.Enabled = Btn_Delete.Enabled = false;
 }
 public CardtoCard(Factor F)
 {
     State = States.WriteF;
     Fa = F;
     InitializeComponent();
     Btn_Edit.Enabled = Btn_Del.Enabled = false;
 }
 /// <summary>
 /// ثبت یک فاکتور
 /// </summary>
 /// <returns></returns>
 private bool RegisterFactor()
 {
     //try
     //{
     _NewID = Convert.ToInt32(DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString());
     string VAXPrice;
     if (ChekVAX.Checked == true)
     {
         VAXPrice = txtVAX.Text.Trim();
     }
     else
     {
         VAXPrice = "0";
     }
     string Des = "ندارد";
     if (txtDescription.Text != "")
     {
         Des = txtDescription.Text;
     }
     DateTime DD = Convert.ToDateTime(Datepicker.GeoDate);
     DateTime D = new DateTime(DD.Year, DD.Month, DD.Day, DateTime.Now.Hour, DateTime.Now.Minute, 0);
     Factor NewFactor = new Factor()
     {
         FactorID = _NewID,
         FactorNumber = txtFactorNumber.Text.ToString().Trim(),
         Date = D,
         TotalPrice = utility.ConvertCommaPrice(txtTotalCost.Text),
         VAX = _VAX,
         VAXPrice = utility.ConvertCommaPrice(VAXPrice),
         Description = Des,
     };
     int projeID = Convert.ToInt32(ComboProject.SelectedValue);
     NewFactor.Project = db.Projects.First(p => p.ProjectID == projeID);
     if (state == 2)
         NewFactor.PurchaseListID = _Purchase.PurchaseListID;
     db.Factors.Add(NewFactor);
     db.SaveChanges();
     if (MessageBox.Show("آیا میخواهید اطلاعات این پرداخت ثبت شود؟", "سوال", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         Form_Payment FP = new Form_Payment(NewFactor);
         FP.ShowDialog();
     }
     if (!RegisterFactorItems())
     {
         db.Factors.Remove(NewFactor);
         utility.Show_Message("ثبت فاکتور انجام نشد", "خطا");
         return false;
     }
     return true;
     //}
     //catch (DbUpdateException ex)
     //{
     //    MessageBox.Show(SqlServerErrorManagment.ShowError(ex, "فاکتور"), "هشدار", MessageBoxButtons.OK, MessageBoxIcon.Error);
     //    return false;
     //}
     //catch (Exception ex)
     //{
     //    MessageBox.Show(ex.Message, "هشدار", MessageBoxButtons.OK, MessageBoxIcon.Error);
     //    return false;
     //}
 }
 private void GetFactor(int FactorID)
 {
     try
     {
         _Factor = (from V in db.Factors.Include("Factor_Items") where V.FactorID == FactorID select V).FirstOrDefault();
     }
     catch (DbUpdateException ex)
     {
         MessageBox.Show(SqlServerErrorManagment.ShowError(ex, "ارزش افزوده"), "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
     }
 }
 public Form_Payment(Factor F)
 {
     State = States.WriteF;
     Fa = F;
     InitializeComponent();
 }
 /// <summary>
 /// نمایش فاکتور ها
 /// </summary>
 private void ShowFactors()
 {
     //try
     //{
     if (GeneralPList.Factors != null)
         OldFactorList = FactorList = GeneralPList.Factors.ToList();
     Factor[] temp = new Factor[OldFactorList.Count];
     OldFactorList.ToList().CopyTo(temp);
     OldFactorList = temp.ToList();
     temp = new Factor[FactorList.Count];
     FactorList.ToList().CopyTo(temp);
     FactorList = temp.ToList();
     if (OldFactorList.Count != 0)
     {
         int i = 0;
         foreach (Factor Factor in OldFactorList)
         {
             GridFactors.Rows.Add();
             GridFactors.Rows[i].Cells["Row"].Value = i + 1;
             GridFactors.Rows[i].Cells["Description"].Value = Factor.Description;
             GridFactors.Rows[i].Cells["Number"].Value = Factor.FactorNumber;
             GridFactors.Rows[i].Cells["TotalPrice"].Value = Factor.TotalPrice;
             GridFactors.Rows[i].Cells["GridFactorDate"].Value = Factor.Date;
             GridFactors.Rows[i].Cells["ProjectName"].Value = Factor.Project.ProjectName;
             GridFactors.Rows[i].Cells["FactorID"].Value = Factor.FactorID;
             i++;
         }
     }
     //}
     //catch (Exception ex)
     //{
     //    MessageBox.Show("خطا" + "\n\n" + ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
     //}
 }