Пример #1
0
 public bool SuaLoaiHH(LoaiHH ch, string id)
 {
     if (ch == null)
     {
         return(false);
     }
     try
     {
         var sql = "update LoaiHH set MaLoai ='" +
                   @ch.MaLoai +
                   "', TenHH='" + @ch.TenLoai +
                   "' where soCMNDChuHo='" + id + "'";
         using (SqlCommand updateCommand = new SqlCommand(sql, connection))
         {
             if (updateCommand.ExecuteNonQuery() == 1)
             {
                 return(true);
             }
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
Пример #2
0
 public bool ThemLoaiHH(LoaiHH ch)
 {
     if (ch == null)
     {
         return(false);
     }
     try
     {
         //MaHH], [TenHH], [MaLoai
         string sql = "insert into " + "LoaiHH(MaLoai, TenLoai,) "
                      + "values(@MaHH, @TenHH, @MaLoai)";
         using (SqlCommand insertCommand = new SqlCommand(sql, connection))
         {
             insertCommand.Parameters.AddWithValue("@MaLoai", ch.MaLoai);
             insertCommand.Parameters.AddWithValue("@TenLoai", ch.TenLoai);
             if (insertCommand.ExecuteNonQuery() == 1)
             {
                 return(true);
             }
         }
     }
     catch
     {
         MessageBox.Show("lỗi phát sinh khi thêm loại hàng hóa.\nThử lại", "Cảnh báo", MessageBoxButtons.OK);
     }
     return(false);
 }
Пример #3
0
 private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     try
     {
         s = new LoaiHH(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(),
                        dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString());
     }
     catch
     {
     }
 }
Пример #4
0
 public SuaLoaiHH(LoaiHH lhh) : this()
 {
     txtMaLoai.Text  = lhh.MaLoai;
     txtTenLoai.Text = lhh.TenLoai;
 }