public BankFish(PurchaseList P)
 {
     State = States.WriteP;
     Pu = P;
     InitializeComponent();
     Btn_Edit.Enabled = Btn_Delete.Enabled = false;
 }
 public CardtoCard(PurchaseList P)
 {
     State = States.WriteP;
     Pu = P;
     InitializeComponent();
     Btn_Edit.Enabled = Btn_Del.Enabled = false;
 }
 /// <summary>
 /// State برای حالت ثبت فاکتور برای تنحواه
 /// </summary>
 /// <param name="_ViewFactor"></param>
 public Form_RegFactorListItem(PurchaseList Purchase)
 {
     InitializeComponent();
     _Purchase = Purchase;
     state = 2;
     Text = Text + " " + "برای لیست تنخواه";
     BGW.RunWorkerAsync();
 }
 public Form_Payment(PurchaseList P)
 {
     State = States.WriteP;
     Pu = P;
     InitializeComponent();
 }
 /// <summary>
 /// Completed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BgwPurchaselist_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     //try
     //{
     if (State == States.Normal || State == States.WithTankhah)
     {
         ShowProjects();
         ShowTankhahCombo();
         GeneralPList = db.PurchaseLists.FirstOrDefault(p => p.PurchaseListID == 0);
         GetContractors();
         ShowContarctorsInCmb();
         btnRegister.Enabled = true;
         BtnNew.Enabled = true;
     }
     else
     {
         ShowProjects();
         ShowTankhahCombo();
         GetContractors();
         ShowContarctorsInCmb();
         btnRegister.Enabled = true;
         btnRegister.Text = "ویرایش";
         ShowPListItems();
         ShowFactors();
         ShowCOSs();
         txtTotalPrice.Text = utility.ConvertPrice(GeneralPList.TotalPrice);
         OldPListPrice = _TotalPrice = utility.ConvertCommaPrice(txtTotalPrice.Text.Trim());
         ShowFormDatas();
     }
     //}
     //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);
     //}
 }
 /// <summary>
 /// dowork
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BgwPurchaselist_DoWork(object sender, DoWorkEventArgs e)
 {
     //try
     //{
     if (State == States.Normal || State == States.WithTankhah)
     {
         GetTankhahs();
         GetProjects();
         GeneralPList = db.PurchaseLists.FirstOrDefault(p => p.PurchaseListID == 0);
     }
     else
     {
         GeneralPList = db.PurchaseLists.Include("Factors").Include("Tankhah").Include("Credit").Include("PurchaseListItems").Include("CostOfServices").FirstOrDefault(p => p.PurchaseListID == newPListID);
         GetTankhahs();
         GetProjects();
     }
     //}
     //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);
     //}
 }
 /// <summary>
 /// اینسرت خود لیست خرید :پی
 /// </summary>
 private void InsertPList()
 {
     //try
     //{
     DateTime DD = Convert.ToDateTime(Datepicker.GeoDate);
     DateTime D = new DateTime(DD.Year, DD.Month, DD.Day, DateTime.Now.Hour, DateTime.Now.Minute, 0);
     newPListID = utility.CreatedNewID();
      newPList = new PurchaseList()
     {
         PurchaseListID = newPListID,
         CreditID = newCreditID,
         Date = D,
         NumberOfList = Convert.ToInt32(NumPListCount.Text.Trim()),
         TankhahID = Convert.ToInt32(CmbTankhah.SelectedValue),
         TotalPrice = _TotalPrice
     };
     db.PurchaseLists.Add(newPList);
     //}
     //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);
     //}
 }