Example #1
0
        public EditCanHo(CanHoDAL caho)
        {
            InitializeComponent();
            maCan_suaCanHo.Text    = caho.maCanHo;
            maCan_suaCanHo.Enabled = false;
            dienTich_suaCanHo.Text = caho.dienTich;
            //  dienTich_suaCanHo.Text = Double.Parse(caho.dienTich).ToString();
            gia_suaCanHo.Text     = caho.giaBan.ToString();
            soPhong_suaCanHo.Text = caho.soPhong.ToString();
            if (caho.trangThai == 1)
            {
                checkBox_daBan.Checked = true;
            }
            if (caho.trangThai == 0)
            {
                checkBox_chuaBan.Checked = true;
            }

            maKhu_suaCanHo.Text = caho.maKhu;
        }
        public int Del_CanHo(CanHoDAL canHoDAL)
        {
            string query = "DELETE CANHO WHERE maCanHo='" + canHoDAL.maCanHo + "'";

            return(DataProvider.Instance.ExcuteNonQuery(query));
        }
        public int Update_CanHo(CanHoDAL canHoDAL)
        {
            string query = "UPDATE CANHO SET dienTich=" + canHoDAL.dienTich + ", giaBan=" + canHoDAL.giaBan + ", trangThai='" + canHoDAL.trangThai + "', soPhong=" + canHoDAL.soPhong + ", maKhu='" + canHoDAL.maKhu + "' where maCanHo='" + canHoDAL.maCanHo + "'";

            return(DataProvider.Instance.ExcuteNonQuery(query));
        }
        public int Add_CanHo(CanHoDAL canHoDAL)
        {
            string query = "insert into CANHO values('" + canHoDAL.maCanHo + "', '" + canHoDAL.dienTich + "', " + canHoDAL.giaBan + ", " + canHoDAL.trangThai + ", " + canHoDAL.soPhong + ",'" + canHoDAL.maKhu + "'); ";

            return(DataProvider.Instance.ExcuteNonQuery(query));
        }
Example #5
0
        private void button_them_AddCanHo_MouseClick(object sender, MouseEventArgs e)
        {
            Regex rex_maCanHo = new Regex(@"^\d{6}$");

            if (!rex_maCanHo.IsMatch(maCanHo_themCanHo.Text))
            {
                MessageBox.Show("Mã căn hộ gồm 6 kí tự.");
            }

            Regex rex_dienTich = new Regex(@"^\d{2,3}$");

            if (!rex_dienTich.IsMatch(dienTich_themCanHo.Text))
            {
                MessageBox.Show("Diện tích.?");
            }

            Regex rex_giaBan = new Regex(@"^\d{4,9}$");

            if (!rex_giaBan.IsMatch(gia_themCanHo.Text))
            {
                MessageBox.Show("Giá bán.?");
            }

            Regex rex_SoPhong = new Regex(@"^\d{1,2}$");

            if (!rex_SoPhong.IsMatch(soPhong_themCanHo.Text))
            {
                MessageBox.Show("Số phòng.?");
            }

            Regex rex_maKhu = new Regex(@"^\D{3}$");

            if (!rex_maKhu.IsMatch(maKhu_themCanHo.Text))
            {
                MessageBox.Show("Mã khu.?");
            }

            if (checkBox_ban.Checked == false && checkBox_chuaBan.Checked == false)
            {
                MessageBox.Show("Check trạng thái.");
            }
            else
            {
                tmp_status = true;
            }

            if (rex_maCanHo.IsMatch(maCanHo_themCanHo.Text) && rex_dienTich.IsMatch(dienTich_themCanHo.Text) && rex_giaBan.IsMatch(gia_themCanHo.Text) && rex_SoPhong.IsMatch(soPhong_themCanHo.Text) && rex_maKhu.IsMatch(maKhu_themCanHo.Text) && tmp_status)
            {
                CanHoDAL caho = new CanHoDAL();
                int      daBan = 1, chuaBan = 0;
                caho.maCanHo  = maCanHo_themCanHo.Text;
                caho.dienTich = dienTich_themCanHo.Text;
                caho.soPhong  = int.Parse(dienTich_themCanHo.Text);
                if (checkBox_ban.Checked)
                {
                    caho.trangThai = Convert.ToByte(daBan);
                }
                if (checkBox_chuaBan.Checked)
                {
                    caho.trangThai = Convert.ToByte(chuaBan);
                }

                caho.maKhu = maKhu_themCanHo.Text;
                if (NhanVien_Controller.Instance.Add_CanHo(caho) > 0)
                {
                    MessageBox.Show("Thêm Thành công..!");
                    var myParent = (CanHo)this.Owner;
                    myParent.RefreshForm();
                    this.Close();
                }
            }
        }