Esempio n. 1
0
        public DieuChuyenBoPhanSuDung Copy()
        {
            DieuChuyenBoPhanSuDung kq = new DieuChuyenBoPhanSuDung();

            kq.DieuChuyenBoPhanSuDungID = dieuChuyenBoPhanSuDungID;
            kq.MaDieuChuyenBoPhanSuDung = maDieuChuyenBoPhanSuDung;
            kq.MaTaiSan       = maTaiSan;
            kq.Nam            = nam;
            kq.Ky             = ky;
            kq.MaBoPhanSuDung = maBoPhanSuDung;
            kq.TKTaiSan       = tKTaiSan;
            kq.TKKhauHao      = tKKhauHao;
            kq.TKChiPhi       = tKChiPhi;
            return(kq);
        }
        private void btnDongY_Click(object sender, EventArgs e)
        {
            try
            {
                DieuChuyenBoPhanSuDung temp = new DieuChuyenBoPhanSuDung();
                temp.DieuChuyenBoPhanSuDungID = idDieuChuyenBoPhanSuDung;
                temp.MaTaiSan = txtMaTaiSan.Text;
                temp.Nam = txtNam.Text;
                temp.Ky = txtKy.Text;
                temp.MaBoPhanSuDung = txtBoPhanSuDung.Text;
                temp.TKTaiSan = txtTKTaiSan.Text;
                temp.TKKhauHao = txtTKKhauHao.Text;
                temp.TKChiPhi = txtTKChiPhi.Text;

                bool ThatBai = false;
                if (Them)
                {//Thêm
                    if (!CheckLoi(temp)) return;

                    int kq = DieuChuyenBoPhanSuDungBiz.AddDieuChuyenBoPhanSuDung(temp);
                    if (kq > 0) MSG.ThemThanhCong();
                    else
                    {
                        ThatBai = true;
                        MSG.ThemThatBai();
                    }
                }
                else
                {//Sửa
                    temp.DieuChuyenBoPhanSuDungID = idDieuChuyenBoPhanSuDung;
                    int kq = DieuChuyenBoPhanSuDungBiz.EditDieuChuyenBoPhanSuDung(temp);
                    if (kq > 0) MSG.SuaThanhCong();
                    else
                    {
                        ThatBai = true;
                        MSG.SuaThatBai();
                    }
                }
                if (ThatBai && MSG.MESSAGE("Bạn có muốn sửa lại dữ liệu không?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) return;
                this.Close();
            }
            catch (Exception ex)
            {
                MSG.Error(ex);
            }
        }
        public static List<DieuChuyenBoPhanSuDung> getListDieuChuyenBoPhanSuDung(string MaTaiSan, int select)
        {
            List<DieuChuyenBoPhanSuDung> kq = new List<DieuChuyenBoPhanSuDung>();
            string sql = string.Empty;
            if (select == 0) sql = "SELECT [DieuChuyenBoPhanSuDungID],[MaDieuChuyenBoPhanSuDung],[MaTaiSan],[Nam],[Ky],[MaBoPhanSuDung],[TKTaiSan],[TKKhauHao],[TKChiPhi] FROM [VNAAccounting].[dbo].[DieuChuyenBoPhanSuDung]";
            else if (select == 1) sql = "SELECT [DieuChuyenBoPhanSuDungID],[MaDieuChuyenBoPhanSuDung],[MaTaiSan],[Nam],[Ky],[MaBoPhanSuDung],[TKTaiSan],[TKKhauHao],[TKChiPhi] FROM [VNAAccounting].[dbo].[DieuChuyenBoPhanSuDung] WHERE MaTaiSan = '" + MaTaiSan + "'";

            System.Data.DataTable dt = DAL.CSDL.hienthi(sql);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DieuChuyenBoPhanSuDung temp = new DieuChuyenBoPhanSuDung();
                temp.DieuChuyenBoPhanSuDungID = int.Parse(dt.Rows[i]["DieuChuyenBoPhanSuDungID"].ToString());
                temp.MaDieuChuyenBoPhanSuDung = dt.Rows[i]["MaDieuChuyenBoPhanSuDung"].ToString();
                temp.MaTaiSan = dt.Rows[i]["MaTaiSan"].ToString();
                temp.Nam = dt.Rows[i]["Nam"].ToString();
                temp.Ky = dt.Rows[i]["Ky"].ToString();
                temp.MaBoPhanSuDung = dt.Rows[i]["MaBoPhanSuDung"].ToString();
                temp.TKTaiSan = dt.Rows[i]["TKTaiSan"].ToString();
                temp.TKKhauHao = dt.Rows[i]["TKKhauHao"].ToString();
                temp.TKChiPhi = dt.Rows[i]["TKChiPhi"].ToString();
                kq.Add(temp);
            }
            return kq;
        }
 public static int EditDieuChuyenBoPhanSuDung(DieuChuyenBoPhanSuDung input)
 {
     string sql = "UPDATE [VNAAccounting].[dbo].[DieuChuyenBoPhanSuDung] SET MaDieuChuyenBoPhanSuDung =N'" + input.MaDieuChuyenBoPhanSuDung.ToUpper() + "',MaTaiSan = N'" + input.MaTaiSan.ToUpper() + "',Nam = N'" + input.Nam + "',Ky = N'" + input.Ky + "',MaBoPhanSuDung = N'" + input.MaBoPhanSuDung + "',TKTaiSan = N'" + input.TKTaiSan + "',TKKhauHao = N'" + input.TKKhauHao + "',TKChiPhi = N'" + input.TKChiPhi + "' WHERE DieuChuyenBoPhanSuDungID = '" + input.DieuChuyenBoPhanSuDungID + "'";
     return DAL.CSDL.ThemSuaXoa(sql);
 }
 public static int DeleteDieuChuyenBoPhanSuDung(DieuChuyenBoPhanSuDung input)
 {
     string sql = "DELETE FROM [VNAAccounting].[dbo].[DieuChuyenBoPhanSuDung] WHERE DieuChuyenBoPhanSuDungID = N'" + input.DieuChuyenBoPhanSuDungID + "'";
     return DAL.CSDL.ThemSuaXoa(sql);
 }
 public static int AddDieuChuyenBoPhanSuDung(DieuChuyenBoPhanSuDung input)
 {
     string sql = "INSERT INTO [VNAAccounting].[dbo].[DieuChuyenBoPhanSuDung]([MaDieuChuyenBoPhanSuDung],[MaTaiSan],[Nam],[Ky],[MaBoPhanSuDung],[TKTaiSan],[TKKhauHao],[TKChiPhi]) VALUES(N'" + input.MaDieuChuyenBoPhanSuDung.ToUpper() + "',N'" + input.MaTaiSan.ToUpper() + "',N'" + input.Nam + "',N'" + input.Ky + "',N'" + input.MaBoPhanSuDung.ToUpper() + "',N'" + input.TKTaiSan + "',N'" + input.TKKhauHao + "',N'" + input.TKChiPhi + "')";
     return DAL.CSDL.ThemSuaXoa(sql);
 }
 bool CheckLoi(DieuChuyenBoPhanSuDung data)
 {
     bool kq = true;
     //mã điều chuyển bộ phận sử dụng rỗng
     if (string.IsNullOrEmpty(data.MaTaiSan))
     {
         MSG.ErrorStand("Bạn chưa nhập mã tài sản!");
         txtMaTaiSan.Focus();
         return false;
     }
     //mã điều chuyển bộ phận sử dụng đã có trong cơ sở dữ liệu
     foreach (DieuChuyenBoPhanSuDung item in frmNVDieuChuyenBoPhanSuDung.Ldata)
     {
         if (item.MaTaiSan.ToUpper().Equals(txtMaTaiSan.Text.ToUpper()))
         {
             MSG.ErrorStand("Mã tài sản đã có trong cơ sở dữ liệu!");
             txtMaTaiSan.Focus();
             return false;
         }
     }
     return kq;
 }
 public DieuChuyenBoPhanSuDung Copy()
 {
     DieuChuyenBoPhanSuDung kq = new DieuChuyenBoPhanSuDung();
     kq.DieuChuyenBoPhanSuDungID = dieuChuyenBoPhanSuDungID;
     kq.MaDieuChuyenBoPhanSuDung = maDieuChuyenBoPhanSuDung;
     kq.MaTaiSan = maTaiSan;
     kq.Nam = nam;
     kq.Ky = ky;
     kq.MaBoPhanSuDung = maBoPhanSuDung;
     kq.TKTaiSan = tKTaiSan;
     kq.TKKhauHao = tKKhauHao;
     kq.TKChiPhi = tKChiPhi;
     return kq;
 }