public List <GuaranteeItemDTO> findItemByProvider(Connection conn, string provider) { List <GuaranteeItemDTO> result = new List <GuaranteeItemDTO>(); string query = "Select * from GuaranteeItem where isDeleted = false and isApproved = false and provider like '" + provider.Trim() + "'"; Console.WriteLine(query); conn.cmd.CommandText = query; using (DbDataReader reader = conn.cmd.ExecuteReader()) { if (!reader.HasRows) { return(new List <GuaranteeItemDTO>()); } else { while (reader.Read()) { GuaranteeItemDTO temp = new GuaranteeItemDTO( reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetBoolean(6), reader.GetBoolean(7)); result.Add(temp); } } } return(result); }
private void btnConfirm_Click(object sender, EventArgs e) { string reason = this.txtReason.Text; string stats = this.txtStatus.Text; if (String.IsNullOrWhiteSpace(reason) || String.IsNullOrWhiteSpace(stats)) { MessageBox.Show( "Dữ liệu nhập vào chưa đủ, vui lòng thử lại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { GuaranteeItemDTO item = new GuaranteeItemDTO(this.parent.currentUser.ID, this.currentitem, this.txtItemProvider.Text, stats, reason, false); if (this.parent.quanLySanPhamBUS.guaranteeItemDAO.AddNewGuaranteeItem(this.parent.conn, item)) { MessageBox.Show( "Thêm thông tin sản phẩm trả thành công!", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show( "Đã có lỗi xảy ra trong quá trình thêm!\nXin vui lòng thử lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool AddNewGuaranteeItem(Connection conn, GuaranteeItemDTO item) { string query = "Insert into GuaranteeItem (createdUser, itemId, provider, status, reason, isApproved)" + "values (" + item.createdUser + ", " + item.itemID + ", '" + item.provider + "', '" + item.stats + "', '" + item.reason + "', " + item.isApproved.ToString() + ")"; conn.cmd.CommandText = query; try { conn.cmd.ExecuteNonQuery(); }catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(false); } return(true); }