private void btnAddMat_Click(object sender, EventArgs e) { //DataGridView dgv = dgvMatList; //string parentCode = ""; ////get parent code by searching plain id in mat_plan db //DataTable dt_Plan = dalPlan.idSearch(planID.ToString()); //foreach (DataRow row_Plan in dt_Plan.Rows) //{ // parentCode = row_Plan[dalItem.ItemCode].ToString(); //} //uJoin.join_parent_code = parentCode; //uJoin.join_child_code = ""; //uJoin.join_qty = 1; //uJoin.join_max = 1; //uJoin.join_min = 1; frmMatAddOrEdit frm = new frmMatAddOrEdit(dt_MaterialPlan); frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog();//Item Edit LoadMatList(); }
private void EditMaterial(int row) { DataGridView dgv = dgvMatList; int planID = int.TryParse(dgv.Rows[row].Cells[headerID].Value.ToString(), out int i) ? Convert.ToInt32(dgv.Rows[row].Cells[headerID].Value.ToString()) : -1; float planToUse = float.TryParse(dgv.Rows[row].Cells[headerMatUse].Value.ToString(), out float j) ? Convert.ToSingle(dgv.Rows[row].Cells[headerMatUse].Value.ToString()) : 0; uMatPlan.plan_id = planID; uMatPlan.part_code = dgv.Rows[row].Cells[headerPartCode].Value.ToString(); uMatPlan.part_name = dgv.Rows[row].Cells[headerPartName].Value.ToString(); uMatPlan.pro_location = dgv.Rows[row].Cells[headerFac].Value.ToString(); uMatPlan.pro_machine = dgv.Rows[row].Cells[headerMac].Value.ToString(); uMatPlan.pro_max_qty = dgv.Rows[row].Cells[headerAbleProduceQty].Value.ToString(); uMatPlan.pro_target_qty = dgv.Rows[row].Cells[headerTargetQty].Value.ToString(); uMatPlan.pro_start = dgv.Rows[row].Cells[headerStart].Value.ToString(); uMatPlan.pro_end = dgv.Rows[row].Cells[headerEnd].Value.ToString(); uMatPlan.mat_code = dgv.Rows[row].Cells[headerMatCode].Value.ToString(); uMatPlan.mat_name = tool.getItemName(uMatPlan.mat_code); uMatPlan.mat_cat = tool.getItemCat(uMatPlan.mat_code); uMatPlan.plan_to_use = planToUse; frmMatAddOrEdit frm = new frmMatAddOrEdit(uMatPlan, false); frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog();//Item Edit LoadMatList(); dgvMatList.FirstDisplayedScrollingRowIndex = row; dgvMatList.Rows[row].Selected = true; }