Пример #1
0
        private void btnUpdateMA_Click(object sender, EventArgs e)
        {
            con = SQLConnection.GetConnection();
            try
            {
                con.Open();

                bool proceed = (dgvMA.Rows.Count - 1) <= int.Parse(SQLConnection.SelectTS("TS_SLMonAn"));

                if (proceed)
                {
                    adapter = new SqlDataAdapter("SELECT * FROM MONAN", con);
                    SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter);
                    cmdBuilder.GetUpdateCommand();
                    cmdBuilder.GetInsertCommand();
                    cmdBuilder.GetDeleteCommand();
                    adapter.Update(ds, "MonAn");
                    MessageBox.Show("Thành công!", "Control Panel", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    changes = true;
                }
                else
                {
                    MessageBox.Show("Lỗi!\n\nQuá số lượng món ăn cho phép", "Control Panel", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi!\n\n" + ex.Message, "Control Panel", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            changes = true;
        }
Пример #2
0
        void CreateDTThang()
        {
            string dateDTNgay = Convert.ToDateTime(SQLConnection.SelectOne("ThoiGian", "DoanhThu_Ngay", "IDPhieuDatPhong = " + _IDPhieuDatPhong))
                                .ToString("MM/yyyy");
            string _ID_DTNgay = SQLConnection.SelectOne("ID_DTNgay", "DoanhThu_Ngay", "IDPhieuDatPhong = " + _IDPhieuDatPhong);

            SqlConnection con = SQLConnection.GetConnection();

            using (con)
            {
                con.Open();
                SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(*) FROM DoanhThu_Thang WHERE ThoiGian LIKE '" + dateDTNgay + "'", con);
                int        result     = int.Parse(sqlCommand.ExecuteScalar().ToString());
                if (result == 0)
                {
                    int    id     = SQLConnection.IncrID("DoanhThu_Thang", "ID_DTThang");
                    string insCol = "ID_DTThang, ThoiGian, ID_DTNgay";
                    string insVal = id + ", '" + dateDTNgay + "', " + _ID_DTNgay;
                    SQLConnection.Insert("DoanhThu_Thang", insCol, insVal);
                }
                else
                {
                    sqlCommand = new SqlCommand("SELECT COUNT(*) FROM DoanhThu_Thang WHERE ID_DTNgay = " + _ID_DTNgay, con);
                    result     = int.Parse(sqlCommand.ExecuteScalar().ToString());
                    if (result == 0)
                    {
                        int    id     = int.Parse(SQLConnection.SelectOne("ID_DTThang", "DoanhThu_Thang", "ThoiGian LIKE '" + dateDTNgay + "'"));
                        string insCol = "ID_DTThang, ThoiGian, ID_DTNgay";
                        string insVal = id + ", '" + dateDTNgay + "', " + _ID_DTNgay;
                        SQLConnection.Insert("DoanhThu_Thang", insCol, insVal);
                    }
                }
            }
        }
Пример #3
0
        void InsertDTNgay()
        {
            string ngayDi = Convert.ToDateTime(SQLConnection.SelectOne("NgayDi", "PhieuDatPhong", "IDPhieuDatPhong = " + _IDPhieuDatPhong))
                            .ToString("MM/dd/yyyy");

            SqlConnection con = SQLConnection.GetConnection();

            using (con)
            {
                con.Open();
                SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(*) FROM DoanhThu_Ngay WHERE ThoiGian = '" + ngayDi + "'", con);
                int        result     = int.Parse(sqlCommand.ExecuteScalar().ToString());

                int id;
                if (result == 0)
                {
                    id = SQLConnection.IncrID("DoanhThu_Ngay", "ID_DTNgay");
                }
                else
                {
                    id = int.Parse(SQLConnection.SelectOne("ID_DTNgay", "DoanhThu_Ngay", "ThoiGian = '" + ngayDi + "'"));
                }
                string insCol = "ID_DTNgay, ThoiGian, IDPhieuDatPhong";
                string insVal = id + ", '" + ngayDi + "', " + _IDPhieuDatPhong;

                SQLConnection.Insert("DoanhThu_Ngay", insCol, insVal);
            }
        }
Пример #4
0
 void CreateTS()
 {
     con = SQLConnection.GetConnection();
     using (con)
     {
         con.Open();
         SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(*) from THAMSO", con);
         int        result     = int.Parse(sqlCommand.ExecuteScalar().ToString());
         if (result == 0)
         {
             string insCol = "TS_LoaiPhong, TS_SLDichVu, TS_SLMonAn, TS_DoiPhongPhat, TS_SoLanDoiPhong";
             string insVal = "'A,B,C', 5, 5, 30, 1";
             SQLConnection.Insert("ThamSo", insCol, insVal);
         }
     }
 }
Пример #5
0
 private void btnUpdateTS_Click(object sender, EventArgs e)
 {
     con = SQLConnection.GetConnection();
     try
     {
         con.Open();
         adapter = new SqlDataAdapter("SELECT * FROM THAMSO", con);
         SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter);
         cmdBuilder.GetUpdateCommand();
         adapter.Update(ds, "ThamSo");
         MessageBox.Show("Thành công!", "Control Panel", MessageBoxButtons.OK, MessageBoxIcon.Information);
         changes = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi!\n\n" + ex.Message, "Control Panel", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Пример #6
0
 private void tabCoupon_Enter(object sender, EventArgs e)
 {
     try
     {
         con = SQLConnection.GetConnection();
         using (con)
         {
             con.Open();
             adapter = new SqlDataAdapter("SELECT * FROM MaGiamGia", con);
             ds      = new DataSet();
             adapter.Fill(ds, "MaGiamGia");
             dgvMGG.DataSource = ds.Tables[0];
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Пример #7
0
        private void btnUpdateRoom_Click(object sender, EventArgs e)
        {
            con = SQLConnection.GetConnection();
            using (con)
            {
                try
                {
                    con.Open();
                    string   TS_LoaiPhong = SQLConnection.SelectTS("TS_LoaiPhong");
                    string[] loaiPhong    = TS_LoaiPhong.Split(',');
                    bool     proceed      = true;
                    for (int i = 0; i < dgvRoom.Rows.Count - 1; i++)
                    {
                        proceed = loaiPhong.Any(dgvRoom.Rows[i].Cells[1].Value.ToString().Contains);
                        if (!proceed)
                        {
                            break;
                        }
                    }

                    if (proceed)
                    {
                        adapter = new SqlDataAdapter("SELECT * FROM PHONG", con);
                        SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter);
                        cmdBuilder.GetUpdateCommand();
                        cmdBuilder.GetInsertCommand();
                        cmdBuilder.GetDeleteCommand();
                        adapter.Update(ds, "Phong");
                        MessageBox.Show("Thành công!", "Control Panel", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        changes = true;
                    }
                    else
                    {
                        MessageBox.Show("Lỗi!\n\nSai loại phòng", "Control Panel", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Lỗi!\n\n" + ex.Message, "Control Panel", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }