private void btnSave_Click(object sender, EventArgs e) { string mouldCode = txtMouldCode.Text; string type = txtType.Text; string jp = txtContentJp.Text; string eng = txtContentEng.Text; string chin = txtContentChin.Text; string itemGroup = txtItemGroup.Text; if (MouldCode.IsMouldCodeValid(mouldCode) && _mode == "new") { MessageBox.Show("Mould Code " + mouldCode + " already exists."); return; } if (_mode == "edit") { string query = string.Format("update TB_MASTER_MOULDCODE set mc_type = N'{0}', mc_contentjp = N'{1}'" + ", mc_contenteng = N'{2}', mc_contentchin = N'{3}', mc_itemgroup = '{4}' where mc_code = '{5}'", type, jp, eng, chin, itemGroup, mouldCode); DataService.GetInstance().ExecuteNonQuery(query); } else { string query = string.Format("insert into TB_MASTER_MOULDCODE (mc_code, mc_type, mc_contentjp" + ", mc_contenteng, mc_contentchin, mc_itemgroup) values ('{0}', N'{1}', N'{2}', N'{3}', N'{4}', '{5}')", mouldCode, type, jp, eng, chin, itemGroup); DataService.GetInstance().ExecuteNonQuery(query); } MessageBox.Show("Record has been saved."); this.DialogResult = DialogResult.OK; }
private List <int> CheckDataList() { List <int> indexList = new List <int>(); foreach (DataGridViewRow row in dgvInput.Rows) { row.DefaultCellStyle.BackColor = SystemColors.ControlLightLight; row.DefaultCellStyle.ForeColor = Color.Black; string mouldCode = row.Cells[7].Value.ToString(); string currency = row.Cells[8].Value.ToString(); string amount = row.Cells[9].Value.ToString(); if (!General.IsValidPrice(amount)) { indexList.Add(row.Index); } if (!MouldCode.IsMouldCodeValid(mouldCode)) { indexList.Add(row.Index); } } indexList = indexList.Distinct().ToList(); return(indexList); }