private void GridFactors_CellMouseClick_1(object sender, DataGridViewCellMouseEventArgs e) { //try //{ if (e.ColumnIndex == GridFactors.Columns["GridFactorRemove"].Index) { if (MessageBox.Show("آیا این فاکتور حذف شود ؟", "اخطار", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign) == DialogResult.Yes) { int FactorID = Convert.ToInt32(GridFactors.Rows[e.RowIndex].Cells["FactorID"].Value); long Cost = db.Factors.FirstOrDefault(p => p.FactorID == FactorID).TotalPrice; int? PID = db.Factors.FirstOrDefault(p => p.FactorID == FactorID).ProjectID; //FactorList = db.Factors.ToList(); db.Factors.Remove(db.Factors.FirstOrDefault(p => p.FactorID == FactorID)); OldFactorList.Remove(db.Factors.FirstOrDefault(p => p.FactorID == FactorID)); db.SaveChanges(); db.Projects.FirstOrDefault(p => p.ProjectID == PID).TotalCost -= Cost; db.SaveChanges(); UpdateFactors(); } } else if (e.ColumnIndex == GridFactors.Columns["View"].Index) { int FactorID = Convert.ToInt32(GridFactors.Rows[e.RowIndex].Cells["FactorID"].Value); int PurchaseListID = GeneralPList.PurchaseListID; Form_RegFactorListItem FF = new Form_RegFactorListItem(PurchaseListID, FactorID); FF.ShowDialog(); UpdateFactors(); } //} //catch (DbUpdateException ex) //{ // Utility.GetScreenShot(" پایگاه داده _سل کلیک گرید فاکتور _" + Utility.ConvertDate(DateTime.Now) + "_Line=" + Utility.GetErrorLine(ex) + "_" + DateTime.Now.Millisecond); // MessageBox.Show(SqlServerErrorManagment.ShowError(ex, "فاکتور") + "\n\n" + ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); // db = new MyDataBase(); //} //catch (Exception ex) //{ // Utility.GetScreenShot("سل کلیک گرید فاکتور _" + Utility.ConvertDate(DateTime.Now) + "_Line=" + Utility.GetErrorLine(ex) + "_" + DateTime.Now.Millisecond); // MessageBox.Show("خطا" + "\n\n" + ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); //} }
/// <summary> /// ایونت ثبت فاکتور /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnFactorRegister_Click(object sender, EventArgs e) { Form_RegFactorListItem FF = new Form_RegFactorListItem(GeneralPList); FF.ShowDialog(); UpdateFactors(); }
/// <summary> /// مشاهده فاکتور انتخابی /// </summary> /// <param name="e"></param> private void ViewFactor(DataGridViewCellMouseEventArgs e) { try { Form_RegFactorListItem F = new Form_RegFactorListItem(Convert.ToInt32(GridFactorList.Rows[e.RowIndex].Cells["FactorID"].Value)); F.ShowDialog(); GridFactorList.Rows.Clear(); GetFactors(); GetProject(); FillGridFactor(); } catch (DbUpdateException ex) { MessageBox.Show(SqlServerErrorManagment.ShowError(ex, "فاکتور"), "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); } }
/// <summary> /// ثبت فاکتور جدید /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Register_Click(object sender, EventArgs e) { try { Form_RegFactorListItem F = new Form_RegFactorListItem(); F.ShowDialog(); GridFactorList.Rows.Clear(); BGW.RunWorkerAsync(); } catch (Exception) { } }
private void Btn_RegTankhah_Click(object sender, EventArgs e) { Form_RegFactorListItem RFL = new Form_RegFactorListItem(); RFL.ShowDialog(); }