Ejemplo n.º 1
0
        public frmStore_Update(string code)
        {
            InitializeComponent();
            statusForm = false;
            lbstatus = "Chỉnh sửa";
            lblChoose.Text = "Tình trạng đang: <b>[" + lbstatus.ToString() + "]</b>";
            Class.clsStore cls = new Class.clsStore();
            cls.StoreCode = code;
            DataTable dt = cls.tbStore_GetbyCode();
            if (dt.Rows.Count > 0)
            {
                txtStoreCode.Enabled = false;
                txtStoreCode.Text = dt.Rows[0]["StoreCode"].ToString();
                txtStoreName.Text = dt.Rows[0]["StoreName"].ToString();
                txtAddress.Text = dt.Rows[0]["Address"].ToString();
                txtTelephone.Text = dt.Rows[0]["Telephone"].ToString();

            }
            this.Text = "Cập nhật kho hàng:  " + dt.Rows[0]["StoreName"].ToString();
        }
Ejemplo n.º 2
0
 private void btnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     //waiting.ShowWaitForm();
     if (gridItemDetail.FocusedRowHandle > -1)//duyệt từ dòng đầu tiên trên lưới
     {
         string code = gridItemDetail.GetFocusedRowCellValue(colStoreCode).ToString();
         Class.clsStore cls = new Class.clsStore();
         cls.StoreCode = code;
         if (MessageBox.Show("Bạn có chắc chắn muốn xoá hay không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             try
             {
                 cls.Delete();
                 MessageBox.Show("Xóa thành công");
                 tbStore_Get();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
Ejemplo n.º 3
0
 //load Grid view
 void tbStore_Get()
 {
     Class.clsStore cls = new Class.clsStore();
     DataTable dt = cls.tbStore_GetList();
     gridItem.DataSource = dt;
 }
Ejemplo n.º 4
0
        private void btnSaveNew_Click(object sender, EventArgs e)
        {
            Class.clsStore cls = new Class.clsStore();

            //Ran buoc du lieu form
            if (txtStoreCode.Text.Trim() == "")
            {

                MessageBox.Show("Bạn chưa nhập mã kho hàng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtStoreCode.Focus();
                return;
            }

            if (txtStoreName.Text.Trim() == "")
            {
                MessageBox.Show("Bạn chưa nhập tên kho hàng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtStoreName.Focus();
                return;
            }
            if (statusForm)
            {
                DataTable dt = cls.tbStore_GetList();
                for (int i = 0; i <= dt.Rows.Count - 1; i++)

                    if (dt.Rows[i]["StoreCode"].ToString().ToLower() == txtStoreCode.Text.ToLower())
                    {
                        MessageBox.Show("Đã tồn tại kho hàng này !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtStoreCode.Focus();
                        return;
                    }

                cls.StoreCode = txtStoreCode.Text;
                cls.StoreName = txtStoreName.Text;
                cls.Address = txtAddress.Text;
                cls.Telephone = txtTelephone.Text;

                if (cls.Insert())
                {
                    MessageBox.Show("Thêm thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    save = true;
                    //this.Close();
                }
                else
                {
                    MessageBox.Show("Thêm thất bại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;
                }
            }
            else
            {

                cls.StoreCode = txtStoreCode.Text;
                cls.StoreName = txtStoreName.Text;
                cls.Address = txtAddress.Text;
                cls.Telephone = txtTelephone.Text;

                if (cls.Update())
                {
                    MessageBox.Show("Sửa thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    save = true;
                    // this.Close();
                }
                else
                {
                    MessageBox.Show("Sửa thất bại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;
                }
            }
            Addnew();
        }