public static bool UpdateLoaiPhieuXuatById(LoaiPhieuXuatDTO loaiPhieuXuatDTO) { List <SqlParameter> sqlParamas = new List <SqlParameter>(); sqlParamas.Add(new SqlParameter("@MaLoaiPhieuXuat", loaiPhieuXuatDTO.MaLoaiPhieuXuat)); sqlParamas.Add(new SqlParameter("@TenLoaiPhieuXuat", loaiPhieuXuatDTO.TenLoaiPhieuXuat)); return(DataProvider.ExecuteNoneQuery("usp_UpdateLoaiPhieuXuatById", sqlParamas)); }
private void buttonYes_Click(object sender, EventArgs e) { bool flag = true; if (dataGridViewLoaiPhieuXuat.Rows[Index].Cells["ColTenLoaiPhieuXuat"].Value == null) { MessageBox.Show("Tên loại phiếu xuất không được để trống"); dataGridViewLoaiPhieuXuat.CurrentCell = dataGridViewLoaiPhieuXuat.Rows[Index].Cells["ColTenLoaiPhieuXuat"]; dataGridViewLoaiPhieuXuat.BeginEdit(true); flag = false; } if (flag) { LoaiPhieuXuatDTO loaiPhieuXuatDTO = new LoaiPhieuXuatDTO(); loaiPhieuXuatDTO.TenLoaiPhieuXuat = dataGridViewLoaiPhieuXuat.Rows[Index].Cells["ColTenLoaiPhieuXuat"].Value.ToString(); if (Status == 1) //Thêm loại phiếu xuất { loaiPhieuXuatDTO.MaLoaiPhieuXuat = LoaiPhieuXuatBUS.CreateLoaiPhieuXuatId(); dataGridViewLoaiPhieuXuat.Rows[Index].Cells["ColMaLoaiPhieuXuat"].Value = loaiPhieuXuatDTO.MaLoaiPhieuXuat; dataGridViewLoaiPhieuXuat.Rows[Index].Cells["ColSTT"].Value = (Index + 1).ToString(); if (LoaiPhieuXuatBUS.InsertLoaiPhieuXuat(loaiPhieuXuatDTO)) { dataGridViewLoaiPhieuXuat.Rows[Index].ReadOnly = true; MessageBox.Show("Thêm thành công"); } else { dataGridViewLoaiPhieuXuat.Rows.RemoveAt(Index); MessageBox.Show("Thêm thất bại"); } } else if (Status == 2) { loaiPhieuXuatDTO.MaLoaiPhieuXuat = dataGridViewLoaiPhieuXuat.Rows[Index].Cells["ColMaLoaiPhieuXuat"].Value.ToString(); if (LoaiPhieuXuatBUS.UpdateLoaiPhieuXuatById(loaiPhieuXuatDTO)) { dataGridViewLoaiPhieuXuat.Rows[Index].ReadOnly = true; MessageBox.Show("Cập nhật thành công"); } else { MessageBox.Show("Cập nhật thất bại"); dataGridViewLoaiPhieuXuat.Rows[Index].Cells["ColTenLoaiPhieuXuat"].Value = BackupThamSoDTO.TenLoaiPhieuXuat; dataGridViewLoaiPhieuXuat.Rows[Index].ReadOnly = true; } } Reset(); } else { dataGridViewLoaiPhieuXuat.BeginEdit(true); } }
private void buttonCapNhat_Click(object sender, EventArgs e) { //Lấy vị trí cần cập nhật Index = dataGridViewLoaiPhieuXuat.CurrentRow.Index; //Lưu lại giá trị cần cập nhật, khôi phục lại khi cập nhật không thành công hoặc hủy LoaiPhieuXuatDTO backup = new LoaiPhieuXuatDTO(); backup.MaLoaiPhieuXuat = dataGridViewLoaiPhieuXuat.CurrentRow.Cells["ColMaLoaiPhieuXuat"].Value.ToString(); backup.TenLoaiPhieuXuat = dataGridViewLoaiPhieuXuat.CurrentRow.Cells["ColTenLoaiPhieuXuat"].Value.ToString(); BackupThamSoDTO = backup; for (int i = 0; i < dataGridViewLoaiPhieuXuat.RowCount; i++) { if (i != Index) { dataGridViewLoaiPhieuXuat.Rows[i].Visible = false; } } //chuyển sang chế độ select cell, cập nhật lại thuộc tính readOnly cho phép chỉnh sữa dataGridViewLoaiPhieuXuat.SelectionMode = DataGridViewSelectionMode.CellSelect; dataGridViewLoaiPhieuXuat.Rows[Index].ReadOnly = false; //Ẩn các cột không cần thiết (STT và mã) dataGridViewLoaiPhieuXuat.Columns["ColSTT"].Visible = false; //Set mặc định ô sẽ chỉnh sữa đầu tiên dataGridViewLoaiPhieuXuat.CurrentCell = dataGridViewLoaiPhieuXuat.Rows[Index].Cells["ColTenLoaiPhieuXuat"]; dataGridViewLoaiPhieuXuat.BeginEdit(true); //Show panel thêm và ẩn đi panel tìm kiếm panelYesNo.Location = new Point(12, 400); panelYesNo.Visible = true; panelTimKiem.Visible = false; buttonYes.Text = "Cập nhật"; groupBoxTimKiem.Enabled = false; groupBoxDSLoaiPhieuXuat.Text = "Cập nhật loại phiếu xuất mới"; //Lưu trạng thái đang thực hiện Status = 2;//Cập nhật loại phiếu xuất }
public static List <LoaiPhieuXuatDTO> SelectLoaiPhieuXuatAll() { DataTable dataTable = DataProvider.ExecuteReader("usp_SelectLoaiPhieuXuatAll"); List <LoaiPhieuXuatDTO> listLoaiPhieuXuatDTO = new List <LoaiPhieuXuatDTO>(); if (dataTable.Rows.Count > 0) { foreach (DataRow dataRow in dataTable.Rows) { LoaiPhieuXuatDTO loaiPhieuXuatDTO = new LoaiPhieuXuatDTO(); loaiPhieuXuatDTO.MaLoaiPhieuXuat = dataRow["MaLoaiPhieuXuat"].ToString(); loaiPhieuXuatDTO.TenLoaiPhieuXuat = dataRow["TenLoaiPhieuXuat"].ToString(); listLoaiPhieuXuatDTO.Add(loaiPhieuXuatDTO); } } else { listLoaiPhieuXuatDTO = null; } return(listLoaiPhieuXuatDTO); }
public static LoaiPhieuXuatDTO SelectLoaiPhieuXuatById(string MaLoaiPhieuXuat) { List <SqlParameter> sqlParamas = new List <SqlParameter>(); sqlParamas.Add(new SqlParameter("@MaLoaiPhieuXuat", MaLoaiPhieuXuat)); DataTable dataTable = DataProvider.ExecuteReader("usp_SelectLoaiPhieuXuatById", sqlParamas); LoaiPhieuXuatDTO loaiPhieuXuatDTO = new LoaiPhieuXuatDTO(); if (dataTable.Rows.Count > 0) { DataRow dataRow = dataTable.Rows[0]; loaiPhieuXuatDTO.MaLoaiPhieuXuat = dataRow["MaLoaiPhieuXuat"].ToString(); loaiPhieuXuatDTO.TenLoaiPhieuXuat = dataRow["TenLoaiPhieuXuat"].ToString(); } else { loaiPhieuXuatDTO = null; } return(loaiPhieuXuatDTO); }
/* * Hàm Khoi Tao * Tải danh sách loại phiếu xuất */ private void KhoiTao() { List <LoaiPhieuXuatDTO> listLoaiPhieuXuatDTO = LoaiPhieuXuatBUS.SelectLoaiPhieuXuatAll(); if (listLoaiPhieuXuatDTO != null) { LoaiPhieuXuatDTO loaiPhieuXuatDTO = new LoaiPhieuXuatDTO(); dataGridViewLoaiPhieuXuat.Rows.Clear(); for (int i = 0; i < listLoaiPhieuXuatDTO.Count; i++) { loaiPhieuXuatDTO = listLoaiPhieuXuatDTO[i]; dataGridViewLoaiPhieuXuat.Rows.Add((i + 1).ToString(), loaiPhieuXuatDTO.MaLoaiPhieuXuat, loaiPhieuXuatDTO.TenLoaiPhieuXuat); dataGridViewLoaiPhieuXuat.Rows[i].ReadOnly = true; } buttonLamLai.Enabled = true; buttonEnabled(); } else { buttonLamLai.Enabled = false; buttonDisabled(); } }
public static bool UpdateLoaiPhieuXuatById(LoaiPhieuXuatDTO loaiPhieuXuatDTO) { return(LoaiPhieuXuatDAO.UpdateLoaiPhieuXuatById(loaiPhieuXuatDTO)); }
public static bool InsertLoaiPhieuXuat(LoaiPhieuXuatDTO loaiPhieuXuatDTO) { return(LoaiPhieuXuatDAO.InsertLoaiPhieuXuat(loaiPhieuXuatDTO)); }