Esempio n. 1
0
        public async Task <ActionResult> deletePhongban(string id)
        {
            var phong = await _context.PhongBan.FindAsync(id);

            if (phong == null)
            {
                return(NotFound());
            }
            ViTri vitri = new ViTri();

            do
            {
                vitri = _context.ViTri.FirstOrDefault(vt => vt.IdPb == id);
                if (vitri != null)
                {
                    _context.ViTri.Remove(vitri);
                    await _context.SaveChangesAsync();
                }
            } while (vitri != null);


            _context.PhongBan.Remove(phong);

            await _context.SaveChangesAsync();

            return(Ok("deleted room " + id));
        }
Esempio n. 2
0
        //FocusedRowChanged in TreePhong
        public void FocusedRowChangedTreePhong()
        {
            DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitForm1), true, true, false);
            DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu...");
            try
            {
                _ViTriHienTai = _ucTreeViTri.getVitri();
                //cosoid = _cosoid;
                //dayid = _dayid;
                //tangid = _tangid;
                //listPhong = Phong.getPhongByViTri(_cosoid, _dayid, _tangid);
                listPhong = PhongHienThi.getPhongByViTri(_ViTriHienTai.coso != null ? _ViTriHienTai.coso.id : Guid.Empty, _ViTriHienTai.day != null ? _ViTriHienTai.day.id : Guid.Empty, _ViTriHienTai.tang != null ? _ViTriHienTai.tang.id : Guid.Empty);
                gridControlPhong.DataSource = listPhong;
                switch (listPhong.Count)
                {
                case 0:
                    deleteData();
                    enableEdit(false);
                    enableBar(false);
                    break;

                default:
                    getThongTinPhong(true);
                    enableEdit(false);
                    enableBar(true);
                    break;
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(this.Name + " : FocusedRowChangedTreePhong : " + ex.Message);
            }
            DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false);
        }
Esempio n. 3
0
        public async Task <IActionResult> deleteNhanVien([FromRoute] string id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var nhanvien = await _context.NhanVien.FindAsync(id);

            if (nhanvien == null)
            {
                return(NotFound());
            }
            ViTri vitri = new ViTri();

            do
            {
                vitri = _context.ViTri.FirstOrDefault(vt => vt.IdNv == id);
                if (vitri != null)
                {
                    _context.ViTri.Remove(vitri);
                    await _context.SaveChangesAsync();
                }
            } while (vitri != null);
            _context.NhanVien.Remove(nhanvien);
            await _context.SaveChangesAsync();

            return(Ok("deleted " + id));
        }
Esempio n. 4
0
 public void setVitri(ViTri obj)
 {
     try
     {
         if (obj != null)
         {
             TreeListNode node = null;
             if (obj.tang != null && !obj.tang.id.Equals(Guid.Empty))
             {
                 node = treeListViTri.FindNodeByKeyID(obj.tang.id);
             }
             else if (obj.day != null && !obj.day.id.Equals(Guid.Empty))
             {
                 node = treeListViTri.FindNodeByKeyID(obj.day.id);
             }
             else if (obj.coso != null && !obj.coso.id.Equals(Guid.Empty))
             {
                 node = treeListViTri.FindNodeByKeyID(obj.coso.id);
             }
             if (node != null)
             {
                 treeListViTri.CollapseAll();
                 node.Selected = true;
             }
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->setVitri : " + ex.Message);
     }
 }
Esempio n. 5
0
 public void loadDataOnlyPhong()
 {
     DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitFormLoad), true, true, false);
     DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu...");
     try
     {
         editGUI("view");
         loadLoaiPhong();
         _ViTriHienTai = _ucTreeViTri.Vitri;
         if (_ViTriHienTai != null)
         {
             listPhong = PhongHienThi.getPhongByViTri(_ViTriHienTai.coso != null ? _ViTriHienTai.coso.id : Guid.Empty, _ViTriHienTai.day != null ? _ViTriHienTai.day.id : Guid.Empty, _ViTriHienTai.tang != null ? _ViTriHienTai.tang.id : Guid.Empty);
         }
         else
         {
             listPhong = null;
         }
         gridControlPhong.DataSource = listPhong;
         if (listPhong == null || listPhong.Count() == 0)
         {
             enableButton(false);
             gridLookUpLoai.EditValue = null;
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->loadData: " + ex.Message);
     }
     DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false);
 }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["ACCOUNT"] == null)
        {
            Response.Redirect("../Login.aspx");
        }

        try
        {
            this.itemId = int.Parse(Request["id"].ToString());
        }
        catch
        {
            this.itemId = 0;
        }
        if (!Page.IsPostBack && this.itemId > 0)
        {
            ViTri objViTri = new ViTri();

            DataRow objData = objViTri.getItem(itemId);
            if (objData != null)
            {
                txtNameTrinhDo.Text   = objData["NameViTri"].ToString();
                txtNote.Text          = objData["Note"].ToString();
                this.ckbState.Checked = (bool)objData["State"];
            }
        }
        this.txtNameTrinhDo.Focus();
    }
Esempio n. 7
0
        public async Task <ActionResult> deleteNhanVienOfPhongban(ViTri vt)
        {
            _context.ViTri.Remove(vt);
            await _context.SaveChangesAsync();

            return(Ok());
        }
Esempio n. 8
0
 public bool checkworking()
 {
     try
     {
         if (function.Equals("add"))
         {
             return
                 (!txtTen.Text.Equals("") ||
                  !txtMoTa.Text.Equals("") ||
                  (txtDiaChi.Properties.ReadOnly && !txtDiaChi.Text.Equals("")) ||
                  listHinh.Count() > 0);
         }
         else if (function.Equals("edit"))
         {
             if (type.Equals("CoSo"))
             {
                 return
                     (objCoSo.ten != txtTen.Text ||
                      objCoSo.mota != txtMoTa.Text ||
                      (txtDiaChi.Text != (objCoSo.diachi != null ? objCoSo.diachi : "")) ||
                      objCoSo.hinhanhs.Except(listHinh).Count() > 0 ||
                      listHinh.Except(objCoSo.hinhanhs).Count() > 0);
             }
             else if (type.Equals("Dayy"))
             {
                 ViTri _vitri = _ucComboBoxViTri.ViTri;
                 return
                     (objDay.ten != txtTen.Text ||
                      objDay.mota != txtMoTa.Text ||
                      objDay.coso != _vitri.coso ||
                      objDay.hinhanhs.Except(listHinh).Count() > 0 ||
                      listHinh.Except(objDay.hinhanhs).Count() > 0);
             }
             else if (type.Equals("Tang"))
             {
                 ViTri _vitri2 = _ucComboBoxViTriChonDay.ViTri;
                 return
                     (objTang.ten != txtTen.Text ||
                      objTang.mota != txtMoTa.Text ||
                      objTang.day != _vitri2.day ||
                      objTang.hinhanhs.Except(listHinh).Count() > 0 ||
                      listHinh.Except(objTang.hinhanhs).Count() > 0);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(working);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->checkworking: " + ex.Message);
         return(true);
     }
 }
Esempio n. 9
0
        public void ToExcel()
        {
            var listVitri = new List <ViTri>();
            var list      = db.ViTris.ToList();

            foreach (var item in list)
            {
                var model = new ViTri();
                model.Mavitri = item.Mavitri;
                model.Khu     = item.Khu;
                model.Ke      = item.Ke;
                model.Ngan    = item.Ngan;
                listVitri.Add(model);
            }


            ExcelPackage   pck = new ExcelPackage();
            ExcelWorksheet ws  = pck.Workbook.Worksheets.Add("Report");

            ws.Cells["A1"].Value = "Communication";
            ws.Cells["B1"].Value = "Com2";

            ws.Cells["A2"].Value = "Report";
            ws.Cells["B2"].Value = "Report2";

            ws.Cells["A3"].Value = "Date";
            ws.Cells["B3"].Value = string.Format("{0:dd MMMM yyyy} at {0:H: mm tt}", DateTimeOffset.Now);

            ws.Cells["A6"].Value = "Mã vị trí";
            ws.Cells["B6"].Value = "Khu";
            ws.Cells["C6"].Value = "Kệ";
            ws.Cells["D6"].Value = "Ngăn";


            int rowStart = 7;

            foreach (var item in list)
            {
                if (item.Mavitri.Count() < 5)
                {
                    ws.Row(rowStart).Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                    ws.Row(rowStart).Style.Fill.BackgroundColor.SetColor(ColorTranslator.FromHtml(string.Format("pink")));
                }

                ws.Cells[string.Format("A{0}", rowStart)].Value = item.Mavitri;
                ws.Cells[string.Format("B{0}", rowStart)].Value = item.Khu;
                ws.Cells[string.Format("C{0}", rowStart)].Value = item.Ke;
                ws.Cells[string.Format("D{0}", rowStart)].Value = item.Ngan;

                rowStart++;
            }

            ws.Cells["A:AZ"].AutoFitColumns();
            Response.Clear();
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment: filename=" + "ExcelReport.xlsx");
            Response.BinaryWrite(pck.GetAsByteArray());
            Response.End();
        }
Esempio n. 10
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        ViTri objViTri = new ViTri();

        objViTri.delData(itemId);

        Response.Redirect("ViTri.aspx");
    }
Esempio n. 11
0
        public ActionResult DeleteConfirmed(int id)
        {
            ViTri viTri = db.ViTris.Find(id);

            db.ViTris.Remove(viTri);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 12
0
        private void editObj(String _type)
        {
            try
            {
                switch (_type)
                {
                case "CoSo":
                    objCoSo.ten  = txtTen.Text;
                    objCoSo.mota = txtMoTa.Text;
                    if (objCoSo.update() > 0 && DBInstance.commit() > 0)
                    {
                        XtraMessageBox.Show("Sửa cơ sở thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        reLoadAndSelectNode(objCoSo.id);
                    }
                    else
                    {
                        XtraMessageBox.Show("Sửa cơ sở không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    break;

                case "Dayy":
                    objDay.ten  = txtTen.Text;
                    objDay.mota = txtMoTa.Text;
                    ViTri _vitri = _ucComboBoxCoSo.ViTri;
                    objDay.coso = _vitri.coso;
                    if (objDay.update() > 0 && DBInstance.commit() > 0)
                    {
                        XtraMessageBox.Show("Sửa dãy thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        reLoadAndSelectNode(objDay.id);
                    }
                    else
                    {
                        XtraMessageBox.Show("Sửa dãy không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    break;

                case "Tang":
                    objTang.ten  = txtTen.Text;
                    objTang.mota = txtMoTa.Text;
                    ViTri _vitri2 = _ucComboBoxDay.ViTri;
                    objTang.day = _vitri2.day;
                    if (objTang.update() > 0 && DBInstance.commit() > 0)
                    {
                        XtraMessageBox.Show("Sửa tầng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        reLoadAndSelectNode(objTang.id);
                    }
                    else
                    {
                        XtraMessageBox.Show("Sửa tầng không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(this.Name + "->editObj: " + ex.Message);
            }
        }
Esempio n. 13
0
 public ActionResult Edit([Bind(Include = "ID,MaViTri,Ngan,Ke,TimeUpdate,TimeCreate,Khu")] ViTri viTri)
 {
     if (ModelState.IsValid)
     {
         db.Entry(viTri).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(viTri));
 }
Esempio n. 14
0
        public ActionResult Create([Bind(Include = "ID,MaViTri,Ngan,Ke,TimeUpdate,TimeCreate,Khu")] ViTri viTri)
        {
            if (ModelState.IsValid)
            {
                db.ViTris.Add(viTri);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(viTri));
        }
Esempio n. 15
0
        public async Task <ActionResult> PostThemViTri(ViTri vtMoi)
        {
            if (vtMoi == null)
            {
                return(BadRequest("Nhân Viên Đã Thuộc Phòng Ban Rồi"));
            }
            await _context.ViTri.AddAsync(vtMoi);

            _context.SaveChanges();
            //   return Ok("Added");
            return(CreatedAtAction(nameof(GetViTriBYId), new { id = vtMoi.IdNv }, vtMoi));
        }
Esempio n. 16
0
        public async Task <ActionResult> deleteVitri(ViTri vitri)
        {
            if (vitri == null)
            {
                return(BadRequest());
            }
            _context.ViTri.Remove(vitri);
            await _context.SaveChangesAsync();


            return(Ok("deleted"));
        }
Esempio n. 17
0
 private void setDataView()
 {
     try
     {
         dxErrorProviderInfo.ClearErrors();
         if (listViTriHienThi.Count > 0)
         {
             if (treeListViTri.FocusedNode != null && treeListViTri.FocusedNode.GetValue(colloai) != null && !GUID.From(treeListViTri.FocusedNode.GetValue(colid)).Equals(Guid.Empty))
             {
                 if (treeListViTri.FocusedNode.GetValue(colloai).ToString().Equals(typeof(CoSo).Name))
                 {
                     editGUI("view", typeof(CoSo).Name);
                     objCoSo      = CoSo.getById(GUID.From(treeListViTri.FocusedNode.GetValue(colid)));
                     txtTen.Text  = objCoSo.ten;
                     txtMoTa.Text = objCoSo.mota;
                     node         = typeof(CoSo).Name;
                 }
                 else if (treeListViTri.FocusedNode.GetValue(colloai).ToString().Equals(typeof(Dayy).Name))
                 {
                     editGUI("view", typeof(Dayy).Name);
                     objDay                = Dayy.getById(GUID.From(treeListViTri.FocusedNode.GetValue(colid)));
                     txtTen.Text           = objDay.ten;
                     txtMoTa.Text          = objDay.mota;
                     node                  = typeof(Dayy).Name;
                     _ucComboBoxCoSo.ViTri = ViTri.request(objDay.coso, null, null);
                 }
                 else if (treeListViTri.FocusedNode.GetValue(colloai).ToString().Equals(typeof(Tang).Name))
                 {
                     editGUI("view", typeof(Tang).Name);
                     objTang              = Tang.getById(GUID.From(treeListViTri.FocusedNode.GetValue(colid)));
                     txtTen.Text          = objTang.ten;
                     txtMoTa.Text         = objTang.mota;
                     node                 = typeof(Tang).Name;
                     _ucComboBoxDay.ViTri = ViTri.request(null, objTang.day, null);
                 }
             }
             else
             {
                 editGUI("nothing", "");
             }
         }
         else
         {
             editGUI("nothing", "");
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->setDataView: " + ex.Message);
     }
 }
Esempio n. 18
0
 public bool checkworking()
 {
     try
     {
         if (function.Equals("add"))
         {
             return
                 (!txtTen.Text.Equals("") ||
                  !txtMoTa.Text.Equals(""));
         }
         else if (function.Equals("edit"))
         {
             if (type.Equals("CoSo"))
             {
                 return
                     (objCoSo.ten != txtTen.Text ||
                      objCoSo.mota != txtMoTa.Text);
             }
             else if (type.Equals("Dayy"))
             {
                 ViTri _vitri = _ucComboBoxCoSo.ViTri;
                 return
                     (objDay.ten != txtTen.Text ||
                      objDay.mota != txtMoTa.Text ||
                      objDay.coso != _vitri.coso);
             }
             else if (type.Equals("Tang"))
             {
                 ViTri _vitri = _ucComboBoxDay.ViTri;
                 return
                     (objTang.ten != txtTen.Text ||
                      objTang.mota != txtMoTa.Text ||
                      objTang.day != _vitri.day);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(working);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->checkworking: " + ex.Message);
         return(true);
     }
 }
Esempio n. 19
0
        // GET: ViTri/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ViTri viTri = db.ViTris.Find(id);

            if (viTri == null)
            {
                return(HttpNotFound());
            }
            return(View(viTri));
        }
Esempio n. 20
0
        public async Task <ActionResult> PostThayDoiViTri(ViTriMoi vtMoi)
        {
            ViTri a = _context.ViTri.Where(s => s.IdNv == vtMoi.IdNv).Where(s => s.IdPb == vtMoi.IdPb).Single();

            if (a == null)
            {
                return(NotFound());
            }

            a.IdPb   = vtMoi.IdPb;
            a.MaLoai = vtMoi.MaLoai;
            await _context.SaveChangesAsync();

            return(Ok("Chage success"));
        }
Esempio n. 21
0
        public ActionResult ListVitri()
        {
            var listVitri = new List <ViTri>();
            var list      = db.ViTris.ToList();

            foreach (var item in list)
            {
                var model = new ViTri();
                model.Mavitri = item.Mavitri;
                model.Khu     = item.Khu;
                model.Ke      = item.Ke;
                model.Ngan    = item.Ngan;
                listVitri.Add(model);
            }
            return(Json(listVitri, JsonRequestBehavior.AllowGet));
        }
Esempio n. 22
0
 public ViTri getVitri()
 {
     try
     {
         ViTri obj = new ViTri();
         obj.coso = CoSo.getById(cosoid);
         obj.day = Dayy.getById(dayid);
         obj.tang = Tang.getById(tangid);
         return obj;
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->getVitri: " + ex.Message);
         return null;
     }
 }
Esempio n. 23
0
 public ViTri getVitri()
 {
     try
     {
         ViTri obj = new ViTri();
         obj.coso = CoSo.getById(cosoid);
         obj.day  = Dayy.getById(dayid);
         obj.tang = Tang.getById(tangid);
         return(obj);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->getVitri: " + ex.Message);
         return(null);
     }
 }
Esempio n. 24
0
 public void FocusedRowChangedTreePhong()
 {
     try
     {
         _ViTriHienTai = _ucTreeViTri.Vitri;
         listPhong     = PhongHienThi.getPhongByViTri(_ViTriHienTai.coso != null ? _ViTriHienTai.coso.id : Guid.Empty, _ViTriHienTai.day != null ? _ViTriHienTai.day.id : Guid.Empty, _ViTriHienTai.tang != null ? _ViTriHienTai.tang.id : Guid.Empty);
         gridControlPhong.DataSource = listPhong;
         if (listPhong.Count() == 0)
         {
             enableButton(false);
             gridLookUpLoai.EditValue = null;
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->FocusedRowChangedTreePhong: " + ex.Message);
     }
 }
Esempio n. 25
0
        private void btnTim_Click(object sender, EventArgs e)
        {
            if (dateNgayTK.EditValue == null)
            {
                dateNgayTK.DateTime = DateTime.Now;
            }
            if (dateNgayTK.DateTime.Year <= 2008)
            {
                XtraMessageBox.Show("Năm thống kê phải lớn hơn 2008", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitFormLoad), true, true, false);
                DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu...");
                try
                {
                    //String ten = checkTen.Checked ? txtTen.Text : null;
                    //String ten = txtTen.Text;
                    LoaiTaiSan  loai       = checkLoaiTS.Checked ? ucComboBoxLoaiTS1.LoaiTS : null;
                    DonVi       DVQL       = ucComboBoxDonVi1.DonVi;
                    ViTri       vitri      = ucComboBoxViTri1.ViTri;
                    Phong       phong      = ucComboBoxViTri1.Phong;
                    List <Guid> tinhtrangs = CheckedComboBoxEditHelper.getCheckedValueArray(checkedCbxTinhTrang);
                    bool        isViTri    = true;
                    if (vitri == null)
                    {
                        isViTri = false;
                    }
                    List <CTTaiSan>      tmp  = CTTaiSanSF.search(null, loai, checkDonVi.Checked, DVQL, false, null, isViTri && checkViTri.Checked, vitri, !isViTri && checkViTri.Checked, phong, checkTinhTrang.Checked ? tinhtrangs : null).ToList();
                    List <TaiSanHienThi> list = TaiSanHienThi.Convert(tmp, dateNgayTK.DateTime.Year);
                    gridControlHaoMon.DataSource = list;

                    //saveSearchXml(this.Name);
                    //ucGridControlTaiSan1.CollapseAllGroups();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(this.Name + "->Search:" + ex.Message);
                }
                DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false);
            }
        }
Esempio n. 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["ACCOUNT"] == null)
        {
            Response.Redirect("../Login.aspx");
        }
        Session["TITLE"] = "VỊ TRÍ TUYỂN";

        ViTri     objViTri = new ViTri();
        DataTable objData  = objViTri.getList();

        cpData.MaxPages      = 1000;
        cpData.PageSize      = 12;
        cpData.DataSource    = objData.DefaultView;
        cpData.BindToControl = dtlData;
        dtlData.DataSource   = cpData.DataSourcePaged;
        dtlData.DataBind();

        index = 1;
    }
Esempio n. 27
0
        public void Search()
        {
            DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitFormLoad), true, true, false);
            DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu...");
            try
            {
                //String ten = checkTen.Checked ? txtTen.Text : null;
                //String ten = txtTen.Text;
                List <Guid> tinhtrangs = CheckedComboBoxEditHelper.getCheckedValueArray(checkedCbxTinhTrang);
                LoaiTaiSan  loai       = checkLoaiTS.Checked ? ucComboBoxLoaiTS1.LoaiTS : null;
                DonVi       DVQL       = ucComboBoxDonVi1.DonVi;
                ViTri       vitri      = ucComboBoxViTri1.ViTri;
                Phong       phong      = ucComboBoxViTri1.Phong;
                bool        isViTri    = true;
                if (vitri == null)
                {
                    isViTri = false;
                }
                List <TaiSanHienThi> list = TaiSanHienThi.Convert(CTTaiSanSF.search(null, loai, checkDonVi.Checked, DVQL, false, null, isViTri && checkViTri.Checked, vitri, !isViTri && checkViTri.Checked, phong, checkTinhTrang.Checked ? tinhtrangs : null,
                                                                                    (cbxEquationDonGia.EditValue != null && checkDonGia.Checked) ? cbxEquationDonGia.EditValue.ToString() : null, (spinDonGia.EditValue != null && checkDonGia.Checked) ? (long?)long.Parse(spinDonGia.EditValue.ToString()) : null,
                                                                                    (cbxEquationNgaySD.EditValue != null && checkNgaySuDung.Checked) ? cbxEquationNgaySD.EditValue.ToString() : null, (dateNgaySD.EditValue != null && checkNgaySuDung.Checked) ? (DateTime?)dateNgaySD.DateTime : null));
                //ucGridControlTaiSan1.DataSource = list;
                gridControlTaiSan.DataSource = list;
                taisans = list;
                //bool isEnabled = list.Count > 0;
                //barBtnSuaTaiSan.Enabled = isEnabled;
                //barBtnXoaTaiSan.Enabled = isEnabled;
                //btnSua_r.Enabled = isEnabled;
                //btnXoa_r.Enabled = isEnabled;

                //saveSearchXml(this.Name);
                //ucGridControlTaiSan1.CollapseAllGroups();
                gridViewTaiSan.CollapseAllGroups();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(this.Name + "->Search:" + ex.Message);
            }
            DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false);
        }
Esempio n. 28
0
 public JsonResult SaveChange(ViTri model, int id)
 {
     try
     {
         if (id > 0)
         {
             var update = db.ViTris.FirstOrDefault(x => x.Mavitri == model.Mavitri);
             update.Khu  = model.Khu;
             update.Ke   = model.Ke;
             update.Ngan = model.Ngan;
             db.SaveChanges();
             return(Json(new JMessage()
             {
                 Error = false, Title = "Cap nhat ban ghi thanh cong !"
             }));
         }
         var checkViTri = db.ViTris.FirstOrDefault(x => x.Mavitri == model.Mavitri);
         if (checkViTri != null)
         {
             return(Json(new JMessage()
             {
                 Error = true, Title = "Bản ghi đã tồn tại !"
             }));
         }
         db.ViTris.Add(model);
         db.SaveChanges();
         return(Json(new JMessage()
         {
             Error = false, Title = "Thêm mới thành công !"
         }));
     }
     catch
     {
         return(Json(new JMessage()
         {
             Error = true, Title = "Đã cõ lỗi xảy ra trong quá trình thực hiện !"
         }));
     }
 }
Esempio n. 29
0
        // Load dữ liệu
        public void loadData()
        {
            try
            {
                //load layout
                layout.load(gridViewPhong);
                canAdd     = Permission.canAdd <Phong>();
                listVitris = ViTriHienThi.getAll().ToList();
                _ucTreeViTri.loadData(listVitris);
                _ucComboBoxViTri.DataSource = listVitris;
                _ViTriHienTai = _ucTreeViTri.getVitri();
                listPhong     = PhongHienThi.getPhongByViTri(_ViTriHienTai.coso != null ? _ViTriHienTai.coso.id : Guid.Empty, _ViTriHienTai.day != null ? _ViTriHienTai.day.id : Guid.Empty, _ViTriHienTai.tang != null ? _ViTriHienTai.tang.id : Guid.Empty);
                gridControlPhong.DataSource = listPhong;
                if (listPhong.Count() == 0)
                {
                    deleteData();
                    enableEdit(false);
                    enableBar(false);
                }
                else
                {
                    getThongTinPhong(true);
                    enableEdit(false);
                    enableBar(true);
                }

                listNhanVienPT = NhanVienPT.getAll();
                NhanVienPT NhanVienPTNULL = new NhanVienPT();
                NhanVienPTNULL.hoten = "[Không có]";
                NhanVienPTNULL.id    = Guid.Empty;
                listNhanVienPT.Insert(0, NhanVienPTNULL);
                searchLookUpEditNhanVienPT.Properties.DataSource = listNhanVienPT;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(this.Name + "->loadData: " + ex.Message);
            }
        }
Esempio n. 30
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        this.lblMsg.Text = "";

        if (this.txtNameTrinhDo.Text.Trim() == "")
        {
            this.lblMsg.Text = "Bạn chưa nhập tên vị trí";
            this.txtNameTrinhDo.Focus();
            return;
        }

        ViTri objViTri = new ViTri();
        int   ret      = objViTri.setData(itemId, this.txtNameTrinhDo.Text.Trim(), txtNote.Text.Trim(), ckbState.Checked);

        if (ret == 0)
        {
            this.lblMsg.Text = "Có lỗi xảy ra!";
        }
        else
        {
            Response.Redirect("ViTri.aspx?id=" + ret);
        }
    }
Esempio n. 31
0
        public void Search()
        {
            DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitFormLoad), true, true, false);
            DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu...");
            try
            {
                //String ten = checkTen.Checked ? txtTen.Text : null;
                String     ten     = txtTen.Text;
                LoaiTaiSan loai    = checkLoai.Checked ? ucComboBoxLoaiTS1.LoaiTS : null;
                DonVi      DVQL    = ucComboBoxDonVi1.DonVi;
                ViTri      vitri   = ucComboBoxViTri1.ViTri;
                Phong      phong   = ucComboBoxViTri1.Phong;
                bool       isViTri = true;
                if (vitri == null)
                {
                    isViTri = false;
                }
                List <Guid>          tinhtrangs = CheckedComboBoxEditHelper.getCheckedValueArray(checkedCbxTinhTrang);
                List <TaiSanHienThi> list       = TaiSanHienThi.Convert(CTTaiSanSF.search(checkTenTS.Checked ? ten : "", checkLoai.Checked ? loai : null, checkDVQL.Checked, DVQL, false, null, isViTri && checkViTri.Checked, vitri, !isViTri && checkViTri.Checked, phong, checkTinhTrang.Checked ? tinhtrangs : null));
                ucGridControlTaiSan1.DataSource = list;


                bool isEnabled = list.Count > 0;
                barBtnSuaTaiSan.Enabled = isEnabled;
                barBtnXoaTaiSan.Enabled = isEnabled;
                btnSua_r.Enabled        = isEnabled;
                btnXoa_r.Enabled        = isEnabled;

                saveSearchXml(this.Name);
                ucGridControlTaiSan1.CollapseAllGroups();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(this.Name + "->Search:" + ex.Message);
            }
            DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false);
        }
Esempio n. 32
0
 private void editGUI(String _function, String _type)
 {
     try
     {
         if (_function.Equals("view"))
         {
             enableEdit(false, true);
             if (_type.Equals(typeof(CoSo).Name))
             {
                 SetTextGroupControl("Chi tiết cơ sở", Color.Empty);
                 showDiaChi(true);
                 //enableCoSoButton(true);
                 //barBtnThemCoSo.Enabled = true;
                 //enableDayButton(false);
                 //barBtnThemDay.Enabled = true;
                 //enableTangButton(false);
                 //barBtnThemTang.Enabled = false;
                 panelControl1.Controls.Clear();
                 panelControl1.Controls.Add(txt);
             }
             else if (_type.Equals(typeof(Dayy).Name))
             {
                 SetTextGroupControl("Chi tiết dãy", Color.Empty);
                 showDiaChi(false);
                 //enableCoSoButton(false);
                 //barBtnThemCoSo.Enabled = true;
                 //enableDayButton(true);
                 //barBtnThemDay.Enabled = true;
                 //enableTangButton(false);
                 //barBtnThemTang.Enabled = true;
                 panelControl1.Controls.Clear();
                 panelControl1.Controls.Add(_ucComboBoxViTri);
             }
             else if (_type.Equals(typeof(Tang).Name))
             {
                 SetTextGroupControl("Chi tiết tầng", Color.Empty);
                 showDiaChi(false);
                 //enableCoSoButton(false);
                 //barBtnThemCoSo.Enabled = true;
                 //enableDayButton(false);
                 //barBtnThemDay.Enabled = true;
                 //enableTangButton(true);
                 //barBtnThemTang.Enabled = true;
                 panelControl1.Controls.Clear();
                 panelControl1.Controls.Add(_ucComboBoxViTriChonDay);
             }
         }
         else if (_function.Equals("add"))
         {
             enableEdit(true);
             enableCoSoButton(false);
             barBtnThemCoSo.Enabled = false;
             enableDayButton(false);
             barBtnThemDay.Enabled = false;
             enableTangButton(false);
             barBtnThemTang.Enabled = false;
             clearText();
             txtTen.Focus();
             if (_type.Equals(typeof(CoSo).Name))
             {
                 SetTextGroupControl("Thêm cơ sở", Color.Red);
                 showDiaChi(true);
                 if (panelControl1.Controls.Count > 0 && !panelControl1.Controls[0].Equals(txt))
                 {
                     panelControl1.Controls.Clear();
                     panelControl1.Controls.Add(txt);
                 }
             }
             else if (_type.Equals(typeof(Dayy).Name))
             {
                 SetTextGroupControl("Thêm dãy", Color.Red);
                 showDiaChi(false);
                 if (panelControl1.Controls.Count > 0 && !panelControl1.Controls[0].Equals(_ucComboBoxViTri))
                 {
                     panelControl1.Controls.Clear();
                     panelControl1.Controls.Add(_ucComboBoxViTri);
                 }
                 ViTri obj = new ViTri();
                 if (node.Equals(typeof(CoSo).Name))
                 {
                     obj.coso = objCoSo;
                 }
                 else if (node.Equals(typeof(Dayy).Name))
                 {
                     obj.coso = objDay.coso;
                 }
                 else if (node.Equals(typeof(Tang).Name))
                 {
                     obj.coso = objTang.day.coso;
                 }
                 _ucComboBoxViTri.ViTri = obj;
             }
             else if (_type.Equals(typeof(Tang).Name))
             {
                 SetTextGroupControl("Thêm tầng", Color.Red);
                 showDiaChi(false);
                 if (panelControl1.Controls.Count > 0 && !panelControl1.Controls[0].Equals(_ucComboBoxViTriChonDay))
                 {
                     panelControl1.Controls.Clear();
                     panelControl1.Controls.Add(_ucComboBoxViTriChonDay);
                 }
                 ViTri obj = new ViTri();
                 if (node.Equals(typeof(Dayy).Name))
                 {
                     obj.day = objDay;
                     obj.coso = objDay.coso;
                 }
                 else if (node.Equals(typeof(Tang).Name))
                 {
                     obj.day = objTang.day;
                     obj.coso = objTang.day.coso;
                 }
                 _ucComboBoxViTriChonDay.ViTri = obj;
             }
         }
         else if (_function.Equals("edit"))
         {
             enableEdit(true);
             enableCoSoButton(false);
             barBtnThemCoSo.Enabled = false;
             enableDayButton(false);
             barBtnThemDay.Enabled = false;
             enableTangButton(false);
             barBtnThemTang.Enabled = false;
             txtTen.Focus();
             if (_type.Equals(typeof(CoSo).Name))
             {
                 SetTextGroupControl("Sửa cơ sở", Color.Red);
                 showDiaChi(true);
                 if (panelControl1.Controls.Count > 0 && !panelControl1.Controls[0].Equals(txt))
                 {
                     panelControl1.Controls.Clear();
                     panelControl1.Controls.Add(txt);
                 }
             }
             else if (_type.Equals(typeof(Dayy).Name))
             {
                 SetTextGroupControl("Sửa dãy", Color.Red);
                 showDiaChi(false);
                 if (panelControl1.Controls.Count > 0 && !panelControl1.Controls[0].Equals(_ucComboBoxViTri))
                 {
                     panelControl1.Controls.Clear();
                     panelControl1.Controls.Add(_ucComboBoxViTri);
                 }
             }
             else if (_type.Equals(typeof(Tang).Name))
             {
                 SetTextGroupControl("Sửa tầng", Color.Red);
                 showDiaChi(false);
                 if (panelControl1.Controls.Count > 0 && !panelControl1.Controls[0].Equals(_ucComboBoxViTriChonDay))
                 {
                     panelControl1.Controls.Clear();
                     panelControl1.Controls.Add(_ucComboBoxViTriChonDay);
                 }
             }
         }
         else if (_function.Equals("nothing"))
         {
             node = typeof(CoSo).Name;
             enableEdit(false, true);
             SetTextGroupControl("Chi tiết", Color.Empty);
             //enableRightButton(false);
             //btnR_Them.Enabled = true;
             //enableCoSoButton(false);
             //barBtnThemCoSo.Enabled = true;
             //enableDayButton(false);
             //barBtnThemDay.Enabled = false;
             //enableTangButton(false);
             //barBtnThemTang.Enabled = false;
             panelControl1.Controls.Clear();
             panelControl1.Controls.Add(txt);
             clearText();
         }
         function = _function;
         type = _type;
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->editGUI:" + ex.Message);
     }
 }
Esempio n. 33
0
 private void setDataView()
 {
     try
     {
         dxErrorProvider1.ClearErrors();
         if (listViTriHienThi.Count > 0)
         {
             if (treeListViTri.FocusedNode != null && treeListViTri.FocusedNode.GetValue(colloai) != null && !GUID.From(treeListViTri.FocusedNode.GetValue(colid)).Equals(Guid.Empty))
             {
                 if (treeListViTri.FocusedNode.GetValue(colloai).ToString().Equals(typeof(CoSo).Name))
                 {
                     editGUI("view", typeof(CoSo).Name);
                     objCoSo = CoSo.getById(GUID.From(treeListViTri.FocusedNode.GetValue(colid)));
                     txtTen.Text = objCoSo.ten;
                     txtDiaChi.Text = objCoSo.diachi;
                     txtMoTa.Text = objCoSo.mota;
                     node = typeof(CoSo).Name;
                     listHinh = objCoSo.hinhanhs.ToList();
                     reloadImage();
                     editGUI2("view", typeof(CoSo).Name);
                 }
                 else if (treeListViTri.FocusedNode.GetValue(colloai).ToString().Equals(typeof(Dayy).Name))
                 {
                     editGUI("view", typeof(Dayy).Name);
                     objDay = Dayy.getById(GUID.From(treeListViTri.FocusedNode.GetValue(colid)));
                     txtTen.Text = objDay.ten;
                     txtMoTa.Text = objDay.mota;
                     node = typeof(Dayy).Name;
                     listHinh = objDay.hinhanhs.ToList();
                     ViTri objViTri = new ViTri();
                     objViTri.coso = objDay.coso;
                     _ucComboBoxViTri.ViTri = objViTri;
                     reloadImage();
                     editGUI2("view", typeof(Dayy).Name);
                 }
                 else if (treeListViTri.FocusedNode.GetValue(colloai).ToString().Equals(typeof(Tang).Name))
                 {
                     editGUI("view", typeof(Tang).Name);
                     objTang = Tang.getById(GUID.From(treeListViTri.FocusedNode.GetValue(colid)));
                     txtTen.Text = objTang.ten;
                     txtMoTa.Text = objTang.mota;
                     node = typeof(Tang).Name;
                     listHinh = objTang.hinhanhs.ToList();
                     ViTri objViTri = new ViTri();
                     objViTri.coso = objTang.day.coso;
                     objViTri.day = objTang.day;
                     _ucComboBoxViTriChonDay.ViTri = objViTri;
                     reloadImage();
                     editGUI2("view", typeof(Tang).Name);
                 }
             }
             else
             {
                 editGUI("nothing","");
                 editGUI2("nothing", "");
             }
         }
         else
         {
             editGUI("nothing", "");
             editGUI2("nothing", "");
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->setDataView: " + ex.Message);
     }
 }
Esempio n. 34
0
 public void FocusedRowChangedTreePhong()
 {
     try
     {
         _ViTriHienTai = _ucTreeViTri.Vitri;
         listPhong = PhongHienThi.getPhongByViTri(_ViTriHienTai.coso != null ? _ViTriHienTai.coso.id : Guid.Empty, _ViTriHienTai.day != null ? _ViTriHienTai.day.id : Guid.Empty, _ViTriHienTai.tang != null ? _ViTriHienTai.tang.id : Guid.Empty);
         gridControlPhong.DataSource = listPhong;
         if (listPhong.Count() == 0)
         {
             enableButton(false);
             gridLookUpLoai.EditValue = null;
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->FocusedRowChangedTreePhong: " + ex.Message);
     }
 }
Esempio n. 35
0
 public void loadDataOnlyPhong()
 {
     DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitFormLoad), true, true, false);
     DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu...");
     try
     {
         editGUI("view");
         loadLoaiPhong();
         _ViTriHienTai = _ucTreeViTri.Vitri;
         if (_ViTriHienTai != null)
             listPhong = PhongHienThi.getPhongByViTri(_ViTriHienTai.coso != null ? _ViTriHienTai.coso.id : Guid.Empty, _ViTriHienTai.day != null ? _ViTriHienTai.day.id : Guid.Empty, _ViTriHienTai.tang != null ? _ViTriHienTai.tang.id : Guid.Empty);
         else
             listPhong = null;
         gridControlPhong.DataSource = listPhong;
         if (listPhong == null || listPhong.Count() == 0)
         {
             enableButton(false);
             gridLookUpLoai.EditValue = null;
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->loadData: " + ex.Message);
     }
     DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false);
 }
Esempio n. 36
0
 //FocusedRowChanged in TreePhong
 public void FocusedRowChangedTreePhong()
 {
     DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(this.ParentForm, typeof(WaitForm1), true, true, false);
     DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Đang tải dữ liệu...");
     try
     {
         _ViTriHienTai = _ucTreeViTri.getVitri();
         //cosoid = _cosoid;
         //dayid = _dayid;
         //tangid = _tangid;
         //listPhong = Phong.getPhongByViTri(_cosoid, _dayid, _tangid);
         listPhong = PhongHienThi.getPhongByViTri(_ViTriHienTai.coso != null ? _ViTriHienTai.coso.id : Guid.Empty, _ViTriHienTai.day != null ? _ViTriHienTai.day.id : Guid.Empty, _ViTriHienTai.tang != null ? _ViTriHienTai.tang.id : Guid.Empty);
         gridControlPhong.DataSource = listPhong;
         switch (listPhong.Count)
         {
             case 0:
                 deleteData();
                 enableEdit(false);
                 enableBar(false);
                 break;
             default:
                 getThongTinPhong(true);
                 enableEdit(false);
                 enableBar(true);
                 break;
         }
     }
     catch (Exception ex)
     {
         System.Console.WriteLine(this.Name + " : FocusedRowChangedTreePhong : " + ex.Message);
     }
     DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(false);
 }
        public static bool ImportPhong(String fileName, String sheet)
        {
            try
            {
                int line = 0;
                System.Data.DataTable dt = new System.Data.DataTable();
                const int STT = 0;
                const int MAPHONG = 1;
                const int TENPHONG = 2;
                const int MOTA = 3;
                const int COSO = 4;
                const int DAY = 5;
                const int TANG = 6;
                const int NHANVIENPT = 7;
                const int MANHANVIEN = 8;
                const int NGAYTAO = 9;
                const int HINHANH = 10;
                const int PASS = 11;
                dt = OpenFile(fileName, sheet);
                if (dt != null)
                {
                    int lines = dt.Rows.Count;
                    foreach (System.Data.DataRow row in dt.Rows)
                    {
                        line++;
                        DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Import Phòng... " +
                            String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0.0}", (line * 1.0 / lines) * 100) + "%");
                        bool ok = false;
                        if (!row[PASS].Equals("Pass"))
                        {
                            if (row[TENPHONG] != DBNull.Value)
                            {
                                if (Phong.getAll().FirstOrDefault(c => c.ten.ToUpper() == row[TENPHONG].ToString().Trim().ToUpper()) == null)
                                {
                                    try
                                    {
                                        ViTri objViTri = new ViTri();
                                        CoSo objCoSo = new CoSo();
                                        Dayy objDay = new Dayy();
                                        Tang objTang = new Tang();
                                        if(row[COSO] != DBNull.Value)
                                        {
                                            objCoSo = CoSo.getAll().Where(c => c.ten.ToUpper().Equals(row[COSO].ToString().Trim().ToUpper())).FirstOrDefault();
                                            if (objCoSo != null && objCoSo.id != Guid.Empty)
                                            {
                                                if (row[DAY] != DBNull.Value && objCoSo.days.Count > 0)
                                                {
                                                    objDay = objCoSo.days.Where(c => c.ten.ToUpper().Equals(row[DAY].ToString().Trim().ToUpper())).FirstOrDefault();
                                                    if (objDay != null && objDay.id != Guid.Empty)
                                                    {
                                                        if (row[TANG] != DBNull.Value && objDay.tangs.Count > 0)
                                                        {
                                                            objTang = objDay.tangs.Where(c => c.ten.ToUpper().Equals(row[TANG].ToString().Trim().ToUpper())).FirstOrDefault();
                                                            if (objTang != null && objTang.id != Guid.Empty)
                                                            {
                                                                objViTri.coso = objCoSo;
                                                                objViTri.day = objDay;
                                                                objViTri.tang = objTang;
                                                                ok = true;
                                                            }
                                                            else
                                                            {
                                                                WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có tầng)");
                                                            }
                                                        }
                                                        else if (row[TANG] == DBNull.Value)
                                                        {
                                                            objViTri.coso = objCoSo;
                                                            objViTri.day = objDay;
                                                            objViTri.tang = null;
                                                            ok = true;
                                                        }
                                                        else
                                                        {
                                                            WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có tầng)");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có dãy)");
                                                    }
                                                }
                                                else if (row[DAY] == DBNull.Value)
                                                {
                                                    objViTri.coso = objCoSo;
                                                    objViTri.day = null;
                                                    objViTri.tang = null;
                                                    ok = true;
                                                }
                                                else
                                                {
                                                    WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có dãy)");
                                                }
                                            }
                                            else
                                            {
                                                WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có cơ sở)");
                                            }
                                        }

                                        if (ok)
                                        {
                                            Phong obj = new Phong();
                                            obj.subId = row[MAPHONG] != DBNull.Value ? row[MAPHONG].ToString().Trim() : null;
                                            obj.vitri = objViTri;
                                            obj.ten = row[TENPHONG].ToString().Trim();
                                            obj.date_create = row[NGAYTAO] != DBNull.Value ? (DateTime?)Convert.ToDateTime(row[NGAYTAO]) : DateTime.Now;
                                            obj.mota = row[MOTA].ToString().Trim();
                                            if (row[HINHANH] != DBNull.Value)
                                            {
                                                String[] file_names = row[HINHANH].ToString().Trim().Split(',');
                                                obj.hinhanhs = AddImage(fileName, file_names);
                                            }

                                            if(row[NHANVIENPT] != DBNull.Value)
                                            {
                                                if (NhanVienPT.getAll().Where(c => c.hoten.ToUpper() == row[NHANVIENPT].ToString().Trim().ToUpper()).Count() == 1)
                                                {
                                                    obj.nhanvienpt = NhanVienPT.getAll().FirstOrDefault(c => c.hoten.ToUpper() == row[NHANVIENPT].ToString().Trim().ToUpper());
                                                }
                                                else if (NhanVienPT.getAll().Where(c => c.hoten.ToUpper() == row[NHANVIENPT].ToString().Trim().ToUpper()).Count() > 1)
                                                {
                                                    if (row[MANHANVIEN] != DBNull.Value)
                                                    {
                                                        if (NhanVienPT.getAll().Where(c => c.hoten.ToUpper() == row[NHANVIENPT].ToString().Trim().ToUpper() && c.subId.ToUpper() == row[MANHANVIEN].ToString().Trim().ToUpper()).Count() == 1)
                                                        {
                                                            obj.nhanvienpt = NhanVienPT.getAll().FirstOrDefault(c => c.hoten.ToUpper() == row[NHANVIENPT].ToString().Trim().ToUpper() && c.subId.ToUpper() == row[MANHANVIEN].ToString().Trim().ToUpper());
                                                        }
                                                        else
                                                        {
                                                            WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass - Error (Mã nhân viên không đúng)");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass - Error (Nhân viên trùng tên nhưng không có mã)");
                                                    }
                                                }
                                            }

                                            if (obj.add() > 0 && DBInstance.commit() > 0)
                                            {
                                                WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass");
                                            }
                                            else
                                            {
                                                WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error");
                                            }
                                        }
                                        else
                                        {
                                            //WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Vị trí lỗi)");
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.WriteLine("ExcelDataBaseHelper->ImportPhong: " + ex.Message);
                                        WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error");
                                    }
                                }
                                else
                                {
                                    WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Exist");
                                }
                            }
                            else
                            {
                                WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không đủ thông tin)");
                            }
                        }
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("ExcelDataBaseHelper->ImportPhong: " + ex.Message);
                return false;
            }
        }
Esempio n. 38
0
 public void setVitri(ViTri obj)
 {
     try
     {
         if (obj != null)
         {
             TreeListNode node = null;
             if (obj.tang != null && !obj.tang.id.Equals(Guid.Empty))
             {
                 node = treeListViTri.FindNodeByKeyID(obj.tang.id);
             }
             else if (obj.day != null && !obj.day.id.Equals(Guid.Empty))
             {
                 node = treeListViTri.FindNodeByKeyID(obj.day.id);
             }
             else if (obj.coso != null && !obj.coso.id.Equals(Guid.Empty))
             {
                 node = treeListViTri.FindNodeByKeyID(obj.coso.id);
             }
             if (node != null)
             {
                 treeListViTri.CollapseAll();
                 node.Selected = true;
             }
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(this.Name + "->setVitri : " + ex.Message);
     }
 }
Esempio n. 39
0
        // Load dữ liệu
        public void loadData()
        {
            try
            {
                //load layout
                layout.load(gridViewPhong);
                canAdd = Permission.canAdd<Phong>();
                listVitris = ViTriHienThi.getAll().ToList();
                _ucTreeViTri.loadData(listVitris);
                _ucComboBoxViTri.DataSource = listVitris;
                _ViTriHienTai = _ucTreeViTri.getVitri();
                listPhong = PhongHienThi.getPhongByViTri(_ViTriHienTai.coso != null ? _ViTriHienTai.coso.id : Guid.Empty, _ViTriHienTai.day != null ? _ViTriHienTai.day.id : Guid.Empty, _ViTriHienTai.tang != null ? _ViTriHienTai.tang.id : Guid.Empty);
                gridControlPhong.DataSource = listPhong;
                if (listPhong.Count() == 0)
                {
                    deleteData();
                    enableEdit(false);
                    enableBar(false);
                }
                else
                {
                    getThongTinPhong(true);
                    enableEdit(false);
                    enableBar(true);
                }

                listNhanVienPT = NhanVienPT.getAll();
                NhanVienPT NhanVienPTNULL = new NhanVienPT();
                NhanVienPTNULL.hoten = "[Không có]";
                NhanVienPTNULL.id = Guid.Empty;
                listNhanVienPT.Insert(0, NhanVienPTNULL);
                searchLookUpEditNhanVienPT.Properties.DataSource = listNhanVienPT;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(this.Name + "->loadData: " + ex.Message);
            }
        }
        public static bool ImportPhong(String fileName, String sheet)
        {
            try
            {
                int line = 0;
                System.Data.DataTable dt = new System.Data.DataTable();
                const int STT = 0;
                const int MAPHONG = 1;
                const int TENPHONG = 2;
                const int LOAIPHONG = 3;
                //const int SOCHONGOI = 4;
                const int MOTA = 5;
                const int COSO = 6;
                const int DAY = 7;
                const int TANG = 8;
                const int PASS = 9;
                dt = OpenFile(fileName, sheet);
                if (dt != null)
                {
                    int lines = dt.Rows.Count;
                    foreach (System.Data.DataRow row in dt.Rows)
                    {
                        line++;
                        DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Import Phòng... " +
                            String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0.0}", (line * 1.0 / lines) * 100) + "%");
                        bool ok = false;
                        if (!row[PASS].Equals("Pass"))
                        {
                            if (row[TENPHONG] != DBNull.Value)
                            {
                                if (Phong.getAll().FirstOrDefault(c => c.ten.ToUpper() == row[TENPHONG].ToString().Trim().ToUpper()) == null)
                                {
                                    try
                                    {
                                        ViTri objViTri = new ViTri();
                                        CoSo objCoSo = new CoSo();
                                        Dayy objDay = new Dayy();
                                        Tang objTang = new Tang();
                                        LoaiPhong objLoai = new LoaiPhong();
                                        if (row[COSO] != DBNull.Value)
                                        {
                                            objCoSo = CoSo.getAll().Where(c => c.ten.ToUpper().Equals(row[COSO].ToString().Trim().ToUpper())).FirstOrDefault();
                                            if (objCoSo != null && objCoSo.id != Guid.Empty)
                                            {
                                                if (row[DAY] != DBNull.Value && objCoSo.days.Count > 0)
                                                {
                                                    objDay = objCoSo.days.Where(c => c.ten.ToUpper().Equals(row[DAY].ToString().Trim().ToUpper())).FirstOrDefault();
                                                    if (objDay != null && objDay.id != Guid.Empty)
                                                    {
                                                        if (row[TANG] != DBNull.Value && objDay.tangs.Count > 0)
                                                        {
                                                            objTang = objDay.tangs.Where(c => c.ten.ToUpper().Equals(row[TANG].ToString().Trim().ToUpper())).FirstOrDefault();
                                                            if (objTang != null && objTang.id != Guid.Empty)
                                                            {
                                                                objViTri.coso = objCoSo;
                                                                objViTri.day = objDay;
                                                                objViTri.tang = objTang;
                                                                ok = true;
                                                            }
                                                            else
                                                            {
                                                                WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có tầng)");
                                                            }
                                                        }
                                                        else if (row[TANG] == DBNull.Value)
                                                        {
                                                            objViTri.coso = objCoSo;
                                                            objViTri.day = objDay;
                                                            objViTri.tang = null;
                                                            ok = true;
                                                        }
                                                        else
                                                        {
                                                            WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có tầng)");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có dãy)");
                                                    }
                                                }
                                                else if (row[DAY] == DBNull.Value)
                                                {
                                                    objViTri.coso = objCoSo;
                                                    objViTri.day = null;
                                                    objViTri.tang = null;
                                                    ok = true;
                                                }
                                                else
                                                {
                                                    WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có dãy)");
                                                }
                                            }
                                            else
                                            {
                                                WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có cơ sở)");
                                            }
                                        }

                                        if (row[LOAIPHONG] != DBNull.Value)
                                        {
                                            objLoai = LoaiPhong.getAll().Where(c => c.ten.ToUpper().Equals(row[LOAIPHONG].ToString().Trim().ToUpper())).FirstOrDefault();
                                            if (objLoai == null || objLoai.id == Guid.Empty)
                                            {
                                                objLoai = new LoaiPhong();
                                                objLoai.ten = row[LOAIPHONG].ToString().Trim();
                                                objLoai.mota = row[LOAIPHONG].ToString().Trim();
                                                //ok = false;
                                                //WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có loại phòng)");
                                            }
                                        }
                                        else
                                        {
                                            ok = false;
                                            WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không có loại phòng)");
                                        }

                                        if (ok)
                                        {
                                            Phong obj = new Phong();
                                            obj.subId = row[MAPHONG] != DBNull.Value ? row[MAPHONG].ToString().Trim() : null;
                                            obj.vitri = objViTri;
                                            obj.ten = row[TENPHONG].ToString().Trim();
                                            //obj.sochongoi = row[SOCHONGOI] != DBNull.Value ? Convert.ToInt32(row[SOCHONGOI].ToString()) : 0;
                                            obj.mota = row[MOTA].ToString().Trim();
                                            obj.loaiphong = objLoai;
                                            if (obj.add() > 0 && DBInstance.commit() > 0)
                                            {
                                                WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Pass");
                                            }
                                            else
                                            {
                                                WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error");
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.WriteLine("ExcelDataBaseHelper->ImportPhong: " + ex.Message);
                                        WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error");
                                    }
                                }
                                else
                                {
                                    WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Exist");
                                }
                            }
                            else
                            {
                                WriteFile(fileName, sheet, row[STT].ToString().Trim(), "Error (Không đủ thông tin)");
                            }
                        }
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("ExcelDataBaseHelper->ImportPhong: " + ex.Message);
                return false;
            }
        }