Пример #1
0
 private void ctMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     if (e.ClickedItem.Name.Equals("ctMenuDelete"))
     {
         string productid = dgChiTietMH.CurrentCell.Value.ToString();
         if (conn.State == ConnectionState.Open)
         {
             conn.Close();
         }
         try
         {
             conn.Open();
             SqlCommand command = new SqlCommand("DELETE FROM Products where ProductID =@ProductID", conn);
             command.Parameters.Add("ProductID", SqlDbType.NChar, 13).Value = productid.ToString();
             command.ExecuteNonQuery();
             conn.Close();
             dgChiTietMH.Refresh();
             dgChiTietMatHangBinding();
         }
         catch (Exception ex)
         {
             MessageBox.Show("Không thể xóa vì còn hóa đơn bán hàng", "errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else if (e.ClickedItem.Name.Equals("ctMenuEdit"))
     {
     }
     else if (e.ClickedItem.Name.Equals("ctMenuNew"))
     {
         frmThemMatHang frmSP = new frmThemMatHang();
         frmSP.Show();
     }
 }
Пример #2
0
        private void BtnThemMatHang_Click(object sender, EventArgs e)
        {
            frmThemMatHang frmThemMH = new frmThemMatHang();

            frmThemMH.Show();
        }