예제 #1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         //DateTime ngayGhi = dateNgayGhi.EditValue != null ? dateNgayGhi.DateTime : DateTime.Now;
         //objChungTu.sohieu = txtSoHieu_CT.Text;
         //objChungTu.ngay = dateNgay_CT.EditValue != null ? dateNgay_CT.DateTime : DateTime.Now;
         int       soLuong   = Convert.ToInt32(txtSoLuong.EditValue);
         TinhTrang tinhTrang = TinhTrang.getById(lookUpTinhTrang.EditValue);
         String    ghiChu    = txtGhiChu.Text;
         CTTaiSan  re        = objCTTaiSan.chuyenTinhTrang(objCTTaiSan.chungtu, tinhTrang, soLuong, ghiChu);
         if (re != null && DBInstance.commit() > 0)
         {
             XtraMessageBox.Show("Chuyển tình trạng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             //Guid id = CTTaiSan.getQuery().Where(c => c.taisan_id == objCTTaiSan.taisan_id && c.tinhtrang_id == tinhTrang.id && c.soluong == soLuong).FirstOrDefault().id;
             if (reloadAndFocused != null)
             {
                 reloadAndFocused(re.id);
             }
             this.Close();
         }
         else
         {
             XtraMessageBox.Show("Chuyển tình trạng không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->btnOK_Click: " + ex.Message);
     }
 }
예제 #2
0
        private Guid editObj()
        {
            try
            {
                objCTTaiSan.taisan.ten    = txtTen.Text;
                objCTTaiSan.taisan.dongia = txtDonGia.EditValue != null?long.Parse(txtDonGia.EditValue.ToString()) : 0;

                objCTTaiSan.taisan.loaitaisan = ucComboBoxLoaiTS1.LoaiTS;
                objCTTaiSan.taisan.subId      = txtMa.Text;

                objChungTu.ngay     = dateNgay_CT.EditValue != null ? dateNgay_CT.DateTime : DateTime.Now;
                objChungTu.sohieu   = txtSoHieu_CT.Text;
                objCTTaiSan.chungtu = objChungTu;

                objCTTaiSan.ngay          = dateNgaySD.EditValue != null ? dateNgaySD.DateTime : DateTime.Now;
                objCTTaiSan.taisan.nuocsx = txtNSX.Text;
                objCTTaiSan.nguongoc      = txtNguonGoc.Text;
                objCTTaiSan.soluong       = Convert.ToInt32(txtSoLuong.EditValue);
                objCTTaiSan.tinhtrang     = TinhTrang.getById(GUID.From(lookUpTinhTrang.EditValue));
                objCTTaiSan.mota          = txtGhiChu.Text;
                objCTTaiSan.childs        = listCTTaiSan;
                int re = objCTTaiSan.update();//ONly call add on CTTaiSan
                //chuyen don vi
                int    soLuongDV = Convert.ToInt32(spinSoLuongDonVi.EditValue);
                Phong  phong     = ucComboBoxViTri1.Phong;
                ViTri  viTri     = ucComboBoxViTri2.ViTri;
                DonVi  donViQL   = ucComboBoxDonVi1.DonVi;
                String ghiChuDV  = txtGhiChuDonVi.Text;
                if (!Object.Equals(objCTTaiSan.phong, phong) || !Object.Equals(objCTTaiSan.vitri, viTri) || !Object.Equals(objCTTaiSan.donviquanly, donViQL))
                {
                    CTTaiSan tmp = objCTTaiSan.chuyenDonVi(donViQL, null, viTri, phong, objCTTaiSan.parent, objCTTaiSan.chungtu, soLuongDV, ghiChuDV);
                    if (tmp != null)
                    {
                        objCTTaiSan = tmp;
                    }
                    else
                    {
                        XtraMessageBox.Show("Sửa tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(Guid.Empty);
                    }
                }
                //chuyen tinh trang
                int       soLuongTT = Convert.ToInt32(spinSoLuongTinhTrang.EditValue);
                TinhTrang tinhTrang = TinhTrang.getById(lookUpChuyenTinhTrang.EditValue);
                String    ghiChuTT  = txtGhiChuTinhTrang.Text;
                if (!Object.Equals(objCTTaiSan.tinhtrang, tinhTrang))
                {
                    CTTaiSan tmp = objCTTaiSan.chuyenTinhTrang(objCTTaiSan.chungtu, tinhTrang, soLuongTT, ghiChuTT);
                    if (tmp == null)
                    {
                        XtraMessageBox.Show("Sửa tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(Guid.Empty);
                    }
                }
                if (!isChild)
                {
                    re = DBInstance.commit();
                }
                if (re > 0)
                {
                    XtraMessageBox.Show("Sửa tài sản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(objCTTaiSan.id);
                }
                else
                {
                    XtraMessageBox.Show("Sửa tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(Guid.Empty);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(this.Name + "->editObj:" + ex.Message);
                return(Guid.Empty);
            }
        }
예제 #3
0
        private Guid addObj()
        {
            try
            {
                TaiSan ts = new TaiSan();
                ts.ten    = txtTen.Text;
                ts.dongia = txtDonGia.EditValue != null?long.Parse(txtDonGia.EditValue.ToString()) : 0;

                ts.loaitaisan = ucComboBoxLoaiTS1.LoaiTS;
                ts.subId      = txtMa.Text;
                ts.nuocsx     = txtNSX.Text;

                CTTaiSan obj = new CTTaiSan();
                objChungTu.ngay   = dateNgay_CT.EditValue != null ? dateNgay_CT.DateTime : DateTime.Now;
                objChungTu.sohieu = txtSoHieu_CT.Text;
                obj.taisan        = ts;
                obj.chungtu       = objChungTu;
                obj.ngay          = dateNgaySD.EditValue != null ? dateNgaySD.DateTime : DateTime.Now;
                obj.nguongoc      = txtNguonGoc.Text;
                obj.soluong       = Convert.ToInt32(txtSoLuong.EditValue);
                obj.tinhtrang     = TinhTrang.getById(GUID.From(lookUpTinhTrang.EditValue));
                obj.mota          = txtGhiChu.Text;
                obj.childs        = listCTTaiSan;
                if (!isChild)
                {
                    int re = obj.add();//ONly call add on CTTaiSan
                    //chuyen don vi
                    int    soLuongDV = Convert.ToInt32(txtSoLuong.EditValue);
                    Phong  phong     = ucComboBoxViTri_PhongN.Phong;
                    ViTri  viTri     = ucComboBoxViTri_ViTriN.ViTri;
                    DonVi  donViQL   = ucComboBoxDonVi_DonViN.DonVi;
                    String ghiChuDV  = txtGhiChu.Text;
                    if (!Object.Equals(obj.phong, phong) || !Object.Equals(obj.vitri, viTri) || !Object.Equals(obj.donviquanly, donViQL))
                    {
                        CTTaiSan tmp = obj.chuyenDonVi(donViQL, null, viTri, phong, obj.parent, obj.chungtu, soLuongDV, ghiChuDV);
                        if (tmp != null)
                        {
                            obj = tmp;
                        }
                        else
                        {
                            XtraMessageBox.Show("Thêm tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(Guid.Empty);
                        }
                    }
                    //chuyen tinh trang
                    //int soLuongTT = Convert.ToInt32(txtSoLuong.EditValue);
                    //TinhTrang tinhTrang = TinhTrang.getById(lookUpTinhTrang.EditValue);
                    //String ghiChuTT = txtGhiChu.Text;
                    //if (!Object.Equals(obj.tinhtrang, tinhTrang))
                    //{
                    //    CTTaiSan tmp = obj.chuyenTinhTrang(obj.chungtu, tinhTrang, soLuongTT, ghiChuTT);
                    //    if (tmp == null)
                    //    {
                    //        XtraMessageBox.Show("Thêm tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //        return Guid.Empty;
                    //    }
                    //}
                    re = DBInstance.commit();
                    if (re > 0)
                    {
                        XtraMessageBox.Show("Thêm tài sản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(obj.id);
                    }
                    else
                    {
                        XtraMessageBox.Show("Thêm tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(Guid.Empty);
                    }
                }
                else
                {
                    int    soLuongDV = Convert.ToInt32(txtSoLuong.EditValue);
                    Phong  phong     = ucComboBoxViTri_PhongN.Phong;
                    ViTri  viTri     = ucComboBoxViTri_ViTriN.ViTri;
                    DonVi  donViQL   = ucComboBoxDonVi_DonViN.DonVi;
                    String ghiChuDV  = txtGhiChu.Text;
                    obj.add();
                    if (!Object.Equals(obj.phong, phong) || !Object.Equals(obj.vitri, viTri) || !Object.Equals(obj.donviquanly, donViQL))
                    {
                        CTTaiSan tmp = obj.chuyenDonVi(donViQL, null, viTri, phong, obj.parent, obj.chungtu, soLuongDV, ghiChuDV);
                        if (tmp != null)
                        {
                            obj = tmp;
                        }
                        else
                        {
                            XtraMessageBox.Show("Thêm tài sản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(Guid.Empty);
                        }
                    }
                    listCTTaiSan2.Add(obj);
                    return(Guid.Empty);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(this.Name + "->addObj:" + ex.Message);
                return(Guid.Empty);
            }
        }