public FormulaMaterial Get(long FormulaID, String MaterialCode, String FormulaPart) { try { SqlParameter[] paramList = new SqlParameter[] { new SqlParameter("@FormulaID", FormulaID), new SqlParameter("@FormulaMaterialCode", MaterialCode), new SqlParameter("@FormulaPart", FormulaPart) }; DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_FormulaMaterial_ByID", paramList); FormulaMaterial obj = new FormulaMaterial(); if (dt.Rows.Count > 0) { obj.Material = objMaterial_DL.Get(Convert.ToString(dt.Rows[0]["FormulaMaterialCode"])); obj.Formula = objFormula_DL.Get(Convert.ToInt32(dt.Rows[0]["FormulaID"])); obj.FormulaPart = Convert.ToString(dt.Rows[0]["FormulaPart"]); obj.FormulaProductQty = Convert.ToDecimal(dt.Rows[0]["FormulaQty"]); } return(obj); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
private void btnMaterialAdd_Click(object sender, EventArgs e) { FormulaMaterial objFormulaMat = new FormulaMaterial(); try { if (cmbMaterials.Items.Count > 0) { objFormulaMat.Material = objMaterialDL.Get(cmbMaterials.SelectedValue.ToString()); objFormulaMat.Formula = objFormula; objFormulaMat.FormulaProductQty = Convert.ToDecimal(txtMaterialQty.Text); objFormulaMat.FormulaPart = cmbMaterialPart.Text.ToString(); objFormulaMaterialDL.Add(objFormulaMat, CurrentUser.UserEmp); bindMaterialList.DataSource = objFormulaMaterialDL.GetDataView_FormulaID(objFormula.FormulaID); bindItemList.DataSource = objFormulaDL.GetDataView_Items(objFormula.FormulaID); } } catch (FormatException fex) { MessageBox.Show(this, "Quantity should be a Numaric value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objFormulaMat = null; } }
public int Update(FormulaMaterial obj) { try { SqlParameter[] paramList = new SqlParameter[] { new SqlParameter("@FormulaPart", obj.FormulaPart), new SqlParameter("@FormulaQty", obj.FormulaProductQty), new SqlParameter("@Original_FormulaID", obj.Formula.FormulaID), new SqlParameter("@Original_FormulaMaterialCode", obj.Material.MaterialCode) }; return(Execute.RunSP_RowsEffected(Connection, "SPUPDATE_FormulaMaterial", paramList)); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public int Add(FormulaMaterial obj, Employee objEmployee) { try { SqlParameter[] paramList = new SqlParameter[] { new SqlParameter("@FormulaID", obj.Formula.FormulaID), new SqlParameter("@FormulaMaterialCode", obj.Material.MaterialCode), new SqlParameter("@FormulaPart", obj.FormulaPart), new SqlParameter("@FormulaQty", obj.FormulaProductQty), new SqlParameter("@FormulaInstructedBy", objEmployee.EmployeeID) }; return(Execute.RunSP_RowsEffected(Connection, "SPADD_FormulaMaterial", paramList)); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
private void cmbMaterialPart_SelectedIndexChanged(object sender, EventArgs e) { FormulaMaterial objFormulaMat = new FormulaMaterial(); try { if (cmbMaterialPart.SelectedIndex != -1) { txtMaterialQty.Text = "0.00"; SelectMaterial = false; lblMaterialUnit.Text = ""; if (cmbMaterials.Items.Count > 0 && cmbMaterials.SelectedItem != null) { Material objMat = objMaterialDL.Get(cmbMaterials.SelectedValue.ToString()); lblMaterialUnit.Text = objMat.MatUnit.UnitCode; if (objFormula.FormulaID != 0) { objFormulaMat = objFormulaMaterialDL.Get(objFormula.FormulaID, objMat.MaterialCode, cmbMaterialPart.SelectedItem.ToString()); if (objFormulaMat.Formula != null) { txtMaterialQty.Text = objFormulaMat.FormulaProductQty.ToString(); //cmbMaterialPart.SelectedItem = objFormulaMat.FormulaPart.Trim(); SelectMaterial = true; } } } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objFormulaMat = null; } }