Ejemplo n.º 1
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (txtBan.Text.Trim() != "" && txtViTri.Text.Trim() != "")
     {
         if (flag == 1) //thêm
         {
             if (Table_BUS.CheckValidTable(txtBan.Text) == 1)
             {
                 string status;
                 if (cbxTinhTrang.Text == "Trống")
                 {
                     status = "0";
                 }
                 else
                 {
                     status = "1";
                 }
                 Table_DTO table = new Table_DTO(txtBan.Text, txtViTri.Text, status);
                 Table_BUS.AddTable(table);
                 MessageBox.Show("Lưu thành công");
             }
             else
             {
                 MessageBox.Show("Đã Tồn tại bàn " + txtBan.Text);
             }
         }
         else //sửa
         {
             string status;
             if (cbxTinhTrang.Text == "Trống")
             {
                 status = "0";
             }
             else
             {
                 status = "1";
             }
             DataRow   row   = gridView1.GetDataRow(gridView1.FocusedRowHandle);
             Table_DTO table = new Table_DTO(txtBan.Text, txtViTri.Text, status);
             Table_BUS.EditTable(table, row[0].ToString());
             MessageBox.Show("Sửa thành công");
         }
         dgvBan.DataSource = Table_BUS.LoadTable();
         bindingData();
         txtBan.ReadOnly      = true;
         txtViTri.ReadOnly    = true;
         cbxTinhTrang.Enabled = false;
         txtSoLuong.Text      = Table_BUS.CountTable().ToString();
         btnLuu.Enabled       = false;
         btnThem.Enabled      = true;
         btnSua.Enabled       = true;
         btnXoa.Enabled       = true;
     }
     else
     {
         MessageBox.Show("Vui lòng điền đầy đủ thông tin");
     }
 }
Ejemplo n.º 2
0
        public static void AddTable(Table_DTO table)
        {
            SqlConnection cnn = ConnectToSQL.Connect();
            SqlCommand    cmd = new SqlCommand("AddTable", cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@Name", SqlDbType.NVarChar, 100);
            cmd.Parameters.Add("@Location", SqlDbType.NVarChar, 200);
            cmd.Parameters.Add("@Status", SqlDbType.NVarChar, 20);
            cmd.Parameters["@Name"].Value     = table.Name;
            cmd.Parameters["@Location"].Value = table.Location;
            cmd.Parameters["@Status"].Value   = table.Status;;
            cnn.Open();
            cmd.ExecuteNonQuery();
            cnn.Close();
        }
Ejemplo n.º 3
0
 public static void EditTable(Table_DTO table, string IdTable)
 {
     Table_DAO.EditTable(table, IdTable);
 }
Ejemplo n.º 4
0
 public static void AddTable(Table_DTO table)
 {
     Table_DAO.AddTable(table);
 }