private void btnThemCT_Click(object sender, EventArgs e) { string maVtStr = this.cbbPhuTung.SelectedValue.ToString(); string soluong = this.txtSoLuong.Text; int maVt = 1; int sl = 0; try { maVt = Int32.Parse(maVtStr); sl = Int32.Parse(soluong); } catch { maVt = 1; sl = 0; } if (maVtStr == "" || soluong == "") { MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Entity_CTPSC _ct = new Entity_CTPSC(Int32.Parse(this.txtMPSC.Text), maVt, sl); //MessageBox.Show(this.maPSC.ToString()); if (ctpsc.insertCTPSC(_ct) == true) { //MessageBox.Show("Thêm thành công Vật tư " + _vt.TenVt, "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); DataGridViewRow row = null; int indexKey = 0; foreach (DataGridViewCell selectedCell in gwPhieuSuaChua.SelectedCells) { DataGridViewRow cell = selectedCell.OwningRow; if (cell.Cells["MAPSC"].Value.ToString() == _ct.MaPsc.ToString()) { indexKey = cell.Index; break; } } reset(); if (indexKey != 0) { this.gwPhieuSuaChua.Rows[0].Selected = false; this.gwPhieuSuaChua.Rows[indexKey].Selected = true; } this.gwCTPhieuSuaChua.DataSource = psc.getPscByID(Int32.Parse(this.txtMPSC.Text)); } else { MessageBox.Show("Vui lòng điền thông tin!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public bool deleteCTPSC(Entity_CTPSC _ct) { try { const string strSQL = "SP_DEL_CTPSC"; string[] pNames = { "@maPsc", "@maVt" }; object[] pValues = { _ct.MaPsc, _ct.MaVt }; int count = con.ExecuteStoredProcedure(strSQL, pNames, pValues); if (count >= 0) { return(true); } else { return(false); } } catch { return(false); } }
public bool deleteCTPSC(Entity_CTPSC _ct) { return(psc.deleteCTPSC(_ct)); }
public bool insertCTPSC(Entity_CTPSC _ct) { return(psc.insertCTPSC(_ct)); }