private void gvPackingType_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { PackingType_DL objPackingTypeDL = new PackingType_DL(ConnectionStringClass.GetConnection()); Form_DL objFormDL = new Form_DL(ConnectionStringClass.GetConnection()); Unit_DL objUnitDL = new Unit_DL(ConnectionStringClass.GetConnection()); try { txtPackingID.Text = Convert.ToString(gvPackingType.CurrentRow.Cells["ColPackingID"].Value); objSelectedPackingType.Type = Convert.ToString(gvPackingType.Rows[e.RowIndex].Cells["ColType"].Value); objSelectedPackingType.PackingID = Convert.ToInt64(gvPackingType.Rows[e.RowIndex].Cells["ColPackingID"].Value); objSelectedPackingType.PackingQty = Convert.ToDecimal(gvPackingType.Rows[e.RowIndex].Cells["ColPackingQty"].Value); objSelectedPackingType.PackingTitle = gvPackingType.Rows[e.RowIndex].Cells["ColPackingTitle"].Value.ToString(); objSelectedPackingType.PackingUnit = objUnitDL.Get(Convert.ToInt64(gvPackingType.Rows[e.RowIndex].Cells["colPackingUnitID"].Value)); txtPackingTypeName.Text = objSelectedPackingType.PackingTitle; txtPackingTypeSize.Text = objSelectedPackingType.PackingQty.ToString(); cmbUnit.SelectedValue = objSelectedPackingType.PackingUnit.UnitID.ToString(); this.PackingTypeSelect = true; } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void Initialize(SqlConnection Conn) { objUnitDL = new Unit_DL(Conn); objFormDL = new Form_DL(Conn); objProductCategoryDL = new ProductCategory_DL(Conn); objProductSubCategory = new ProductSubCategory_DL(Conn); objFormulaDL = new Formula_DL(Conn); objPackingTypeDL = new PackingType_DL(Conn); objFinishProductDL = new FinishProduct_DL(Conn); objbasicProductDL = new BasicProduct_DL(Conn); }
private void btnPackinTypeDelete_Click(object sender, EventArgs e) { if (this.PackingTypeSelect) { DialogResult dr = MessageBox.Show(this, "Are you sure, You want to Delete selected Record?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { PackingType_DL objpackingTypeDL = new PackingType_DL(ConnectionStringClass.GetConnection()); try { int x = objpackingTypeDL.Delete(objSelectedPackingType.PackingID); gvPackingType.DataSource = objpackingTypeDL.GetDataView(); cmbUnit.SelectedIndex = 0; txtPackingTypeName.Text = ""; txtPackingTypeSize.Text = "0.00"; this.PackingTypeSelect = false; if (x > 0) { MessageBox.Show(this, "Succesfully Deleted", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objpackingTypeDL = null; } } } else { MessageBox.Show(this, "Select a Record from the List", "Select a Record", MessageBoxButtons.OK, MessageBoxIcon.Information); } }