private void dgv_CategoryDetails_CellContentClick(object sender, DataGridViewCellEventArgs e) { string s = dgv_CategoryDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString(); if (s == "ترمیم") { CatagoryDetails.temp = dgv_CategoryDetails.Rows[e.RowIndex].Cells[0].FormattedValue.ToString(); txt_CategoryName.Text = CatagoryDetails.temp; txt_CategoryDetails.Text = dgv_CategoryDetails.Rows[e.RowIndex].Cells[1].FormattedValue.ToString(); cmb_CategoryHeadName.Text = dgv_CategoryDetails.Rows[e.RowIndex].Cells[3].FormattedValue.ToString(); categoryId = Convert.ToInt32(dgv_CategoryDetails.Rows[e.RowIndex].Cells[6].FormattedValue); editFlag = true; } else if (s == "حزف کریں") { CatagoryDetails catDetails = new CatagoryDetails(); catDetails.categoryId = Convert.ToInt32(dgv_CategoryDetails.Rows[e.RowIndex].Cells[6].FormattedValue); catDetails.Delete(catDetails.categoryId); MedDbEntities db = new MedDbEntities(); var p = db.Categories.ToList(); dgv_CategoryDetails.DataSource = db.Categories.ToList(); int rows = dgv_CategoryDetails.Rows.Count; for (int i = 0; i < rows; i++) { string s1 = dgv_CategoryDetails.Rows[i].Cells[2].FormattedValue.ToString(); if (s1 != "") { dgv_CategoryDetails.Rows[i].Cells[3].Value = catDetails.getCategoryNameFromId(Convert.ToInt32(s1)); } } } }
public void load() { CatagoryDetails catDetails = new CatagoryDetails(); int rows = dgv_CategoryDetails.Rows.Count; for (int i = 0; i < rows; i++) { string s = dgv_CategoryDetails.Rows[i].Cells[2].FormattedValue.ToString(); if (s != "") { dgv_CategoryDetails.Rows[i].Cells[3].Value = catDetails.getCategoryNameFromId(Convert.ToInt32(s)); } } }
private void btn_SaveCategory_Click_1(object sender, EventArgs e) { if (string.IsNullOrEmpty(txt_CategoryDetails.Text) || string.IsNullOrWhiteSpace(txt_CategoryDetails.Text) || string.IsNullOrEmpty(txt_CategoryName.Text) || string.IsNullOrWhiteSpace(txt_CategoryName.Text)) { MessageBox.Show("کیٹیگری کا نام اور تفصیلات درج کریں"); return; } if (editFlag == false) { CatagoryDetails catDetails = new CatagoryDetails(); catDetails.catagoryName = txt_CategoryName.Text; catDetails.catagoryDescription = txt_CategoryDetails.Text; catDetails.catagoryParentName = cmb_CategoryHeadName.Text; if (catDetails.Add() == true) { MessageBox.Show("!کیٹیگوری محفوز ہو چکی ہے"); MedDbEntities db = new MedDbEntities(); var p = db.Categories.ToList(); dgv_CategoryDetails.DataSource = db.Categories.ToList(); int rows = dgv_CategoryDetails.Rows.Count; for (int i = 0; i < rows; i++) { string s = dgv_CategoryDetails.Rows[i].Cells[2].FormattedValue.ToString(); if (s != "") { dgv_CategoryDetails.Rows[i].Cells[3].Value = catDetails.getCategoryNameFromId(Convert.ToInt32(s)); } } txt_CategoryName.Clear(); txt_CategoryDetails.Clear(); } else { MessageBox.Show("کیٹیگی پہلے سے موجود ہے"); //catDetails.AddCatagoryParentNameToCombobox(cmb_CategoryHeadName); } } else { CatagoryDetails catDetails = new CatagoryDetails(); catDetails.catagoryName = txt_CategoryName.Text; catDetails.catagoryDescription = txt_CategoryDetails.Text; catDetails.categoryId = categoryId; catDetails.catagoryParentName = cmb_CategoryHeadName.Text; if (catDetails.Edit() == true) { MessageBox.Show("!کیٹیگوری محفوز ہو چکی ہے"); MedDbEntities db = new MedDbEntities(); var p = db.Categories.ToList(); dgv_CategoryDetails.DataSource = db.Categories.ToList(); int rows = dgv_CategoryDetails.Rows.Count; for (int i = 0; i < rows; i++) { string s = dgv_CategoryDetails.Rows[i].Cells[2].FormattedValue.ToString(); if (s != "") { dgv_CategoryDetails.Rows[i].Cells[3].Value = catDetails.getCategoryNameFromId(Convert.ToInt32(s)); } } txt_CategoryName.Clear(); txt_CategoryDetails.Clear(); } else { MessageBox.Show("کیٹیگی پہلے سے موجود ہے"); } } }