private void Xoa()
 {
     try
     {
         if (vtIndex != -1)  //khi click lên tiêu đề header của datagrid thì bỏ qua
         {
             if (MSG.BanCoChacChanMuonXoaKhong() == System.Windows.Forms.DialogResult.Yes)
             {
                 BoPhanSuDung temp = Utils.DataGridViewRow_to_BoPhanSuDung(DataGridView.Rows[vtIndex]);
                 int          kq   = BoPhanSuDungBiz.DeleteBoPhanSuDung(temp);
                 //if (kq > 0) MSG.XoaThanhCong();
                 //else MSG.XoaThatBai();
                 if (kq <= 0)
                 {
                     MSG.XoaThatBai();
                 }
                 HienThi();
             }
         }
     }
     catch (Exception ex)
     {
         MSG.Error(ex);
     }
 }
Beispiel #2
0
        public static BoPhanSuDung DataGridViewRow_to_BoPhanSuDung(System.Windows.Forms.DataGridViewRow Input)
        {
            BoPhanSuDung kq = new BoPhanSuDung();

            kq.MaBoPhanSuDung  = Input.Cells["MaBoPhanSuDung"].Value.ToString();
            kq.TenBoPhanSuDung = Input.Cells["TenBoPhanSuDung"].Value.ToString();
            return(kq);
        }
 public frmXuLyDMBoPhanSuDung(DataGridViewRow dgvr)
 {//Sửa
     InitializeComponent();
     try
     {
         Them = false;
         BoPhanSuDung temp = Utils.DataGridViewRow_to_BoPhanSuDung(dgvr);
         txtMa.Text    = temp.MaBoPhanSuDung;
         txtMa.Enabled = false;
         txtTen.Text   = temp.TenBoPhanSuDung;
     }
     catch { }
 }
Beispiel #4
0
        public static List <BoPhanSuDung> getListBoPhanSuDung()
        {
            List <BoPhanSuDung> kq = new List <BoPhanSuDung>();
            string sql             = "SELECT [MaBoPhanSuDung],[TenBoPhanSuDung] FROM  [VNAAccounting].[dbo].[BoPhanSuDung]";

            System.Data.DataTable dt = DAL.CSDL.hienthi(sql);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                BoPhanSuDung temp = new BoPhanSuDung();
                temp.MaBoPhanSuDung  = dt.Rows[i]["MaBoPhanSuDung"].ToString();
                temp.TenBoPhanSuDung = dt.Rows[i]["TenBoPhanSuDung"].ToString();
                kq.Add(temp);
            }
            return(kq);
        }
        private void btnDongY_Click(object sender, EventArgs e)
        {
            if (Them)
            {//Thêm
                BoPhanSuDung temp = new BoPhanSuDung();
                temp.MaBoPhanSuDung  = txtMa.Text;
                temp.TenBoPhanSuDung = txtTen.Text;

                if (!CheckLoi(temp))
                {
                    return;
                }

                int kq = BoPhanSuDungBiz.AddBoPhanSuDung(temp);
                if (kq > 0)
                {
                    MSG.ThemThanhCong();
                }
                else
                {
                    MSG.ThemThatBai();
                }
            }
            else
            {//Sửa
                BoPhanSuDung temp = new BoPhanSuDung();
                temp.MaBoPhanSuDung  = txtMa.Text;
                temp.TenBoPhanSuDung = txtTen.Text;
                int kq = BoPhanSuDungBiz.EditBoPhanSuDung(temp);
                if (kq > 0)
                {
                    MSG.SuaThanhCong();
                }
                else
                {
                    MSG.SuaThatBai();
                }
            }
            this.Close();
        }
        bool CheckLoi(BoPhanSuDung data)
        {
            bool kq = true;

            //mã bộ phận sử dụng rỗng
            if (string.IsNullOrEmpty(data.MaBoPhanSuDung))
            {
                MSG.ErrorStand("Bạn chưa nhập mã bộ phận sử dụng!");
                txtMa.Focus();
                return(false);
            }
            //mã bộ phận sử dụng đã có trong cơ sở dữ liệu
            foreach (BoPhanSuDung item in frmDMBoPhanSuDung.Ldata)
            {
                if (item.MaBoPhanSuDung.ToUpper().Equals(txtMa.Text.ToUpper()))
                {
                    MSG.ErrorStand("Mã bộ phận sử dụng đã có trong cơ sở dữ liệu!");
                    txtMa.Focus();
                    return(false);
                }
            }
            return(kq);
        }
Beispiel #7
0
        //------------------------------------------>
        private void DongY()
        {
            if (vtIndex == -1)
            {
                return;
            }
            switch (chose)
            {
            case CONFIG.ConstFrm.frmDMLoaiTaiSan:
            {
                loaitaisan = Utils.DataGridViewRow_to_LoaiTaiSan(DataGridView.Rows[vtIndex]);
                break;
            }

            case CONFIG.ConstFrm.frmDMTaiSan:
            {
                taisan = Utils.DataGridViewRow_to_TaiSan(DataGridView.Rows[vtIndex]);
                break;
            }

            case CONFIG.ConstFrm.frmDMPhanNhomTaiSan:
            {
                phannhomtaisan = Utils.DataGridViewRow_to_PhanNhomTaiSan(DataGridView.Rows[vtIndex]);
                break;
            }

            case CONFIG.ConstFrm.frmDMLyDoTangGiamTaiSan:
            {
                lydotanggiamtaisan = Utils.DataGridViewRow_to_LyDoTangGiamTaiSan(DataGridView.Rows[vtIndex]);
                break;
            }

            case CONFIG.ConstFrm.frmDMBoPhanHachToan:
            {
                bophanhachtoan = Utils.DataGridViewRow_to_BoPhanHachToan(DataGridView.Rows[vtIndex]);
                break;
            }

            case CONFIG.ConstFrm.frmDMPhanXuong:
            {
                phanxuong = Utils.DataGridViewRow_to_PhanXuong(DataGridView.Rows[vtIndex]);
                break;
            }

            case CONFIG.ConstFrm.frmDMPhi:
            {
                phi = Utils.DataGridViewRow_to_Phi(DataGridView.Rows[vtIndex]);
                break;
            }

            case CONFIG.ConstFrm.frmDMBoPhanSuDung:
            {
                bophansusung = Utils.DataGridViewRow_to_BoPhanSuDung(DataGridView.Rows[vtIndex]);
                break;
            }

            case CONFIG.ConstFrm.frmDMNguonVon:
            {
                nguonvon = Utils.DataGridViewRow_to_NguonVon(DataGridView.Rows[vtIndex]);
                break;
            }

            default:
                break;
            }
        }
Beispiel #8
0
        public static int DeleteBoPhanSuDung(BoPhanSuDung input)
        {
            string sql = "DELETE FROM [VNAAccounting].[dbo].[BoPhanSuDung] WHERE MaBoPhanSuDung = N'" + input.MaBoPhanSuDung.ToUpper() + "'";

            return(DAL.CSDL.ThemSuaXoa(sql));
        }
Beispiel #9
0
        public static int EditBoPhanSuDung(BoPhanSuDung input)
        {
            string sql = "UPDATE [VNAAccounting].[dbo].[BoPhanSuDung] SET TenBoPhanSuDung = N'" + input.TenBoPhanSuDung + "' WHERE MaBoPhanSuDung = N'" + input.MaBoPhanSuDung.ToUpper() + "'";

            return(DAL.CSDL.ThemSuaXoa(sql));
        }
Beispiel #10
0
        public static int AddBoPhanSuDung(BoPhanSuDung input)
        {
            string sql = "INSERT INTO [VNAAccounting].[dbo].[BoPhanSuDung]([MaBoPhanSuDung],[TenBoPhanSuDung]) VALUES(N'" + input.MaBoPhanSuDung.ToUpper() + "',N'" + input.TenBoPhanSuDung + "')";

            return(DAL.CSDL.ThemSuaXoa(sql));
        }