Esempio n. 1
0
        /// <summary>
        /// Đóng gói dữ liệu vào DataTable để gửi lên Webservice xử lý
        /// </summary>
        /// <returns></returns>
        private DmucKieudmuc GetObject()
        {
            try
            {
                DmucKieudmuc obj = new DmucKieudmuc();
                if (m_enAct == action.Update)
                {
                    obj.Id = Utility.Int32Dbnull(txtID.Text, 0);
                }
                obj.MaLoai  = Utility.DoTrim(txtMa.Text);
                obj.TenLoai = Utility.DoTrim(txtTen.Text);

                obj.TrangThai = Convert.ToByte(chkTrangthai.Checked ? 1 : 0);
                obj.MotaThem  = Utility.DoTrim(txtMotathem.Text);
                if (m_enAct == action.Update)
                {
                    obj.NguoiSua = globalVariables.UserName;
                    obj.NgaySua  = globalVariables.SysDate;
                }
                else
                {
                    obj.NguoiTao = globalVariables.UserName;
                    obj.NgayTao  = globalVariables.SysDate;
                }
                return(obj);
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi xảy ra khi đóng gói dữ liệu vào DataTable để gửi lên Webservice\n" + ex.Message, "Thông báo");
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Update một bản ghi vào bảng Danh mục dùng chung
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>

        public void UpdateList(DmucKieudmuc obj, string strOldCode, ref string ActResult)
        {
            try
            {
                ActionResult _act = isExistedRecord4Update(obj.MaLoai, strOldCode);
                if (_act == ActionResult.ExistedRecord || _act == ActionResult.Exception)
                {
                    ActResult = _act.ToString();
                    return;
                }
                int record = new Update(DmucKieudmuc.Schema)
                             .Set(DmucKieudmuc.Columns.MaLoai).EqualTo(obj.MaLoai)
                             .Set(DmucKieudmuc.Columns.TenLoai).EqualTo(obj.TenLoai)
                             .Set(DmucKieudmuc.Columns.MotaThem).EqualTo(obj.MotaThem)
                             .Set(DmucKieudmuc.Columns.TrangThai).EqualTo(obj.TrangThai)
                             .Set(DmucKieudmuc.Columns.NgaySua).EqualTo(obj.NgaySua)
                             .Set(DmucKieudmuc.Columns.NguoiSua).EqualTo(obj.NguoiSua)
                             .Where(DmucKieudmuc.Columns.Id).IsEqualTo(obj.Id).Execute();
                if (record > 0)
                {
                    //Update trong bảng danh mục
                    new Update(DmucChung.Schema).Set(DmucChung.Columns.Loai).EqualTo(obj.MaLoai)
                    .Where(DmucChung.Columns.Loai).IsEqualTo(strOldCode).Execute();
                    ActResult = ActionResult.Success.ToString();
                }
                else
                {
                    ActResult = ActionResult.Error.ToString();
                }
            }
            catch
            {
                ActResult = ActionResult.Exception.ToString();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Thực hiện thêm mới dữ liệu
        /// </summary>
        private bool PerformInserAct()
        {
            try
            {
                //Kiem tra su hop le cua du lieu
                if (!IsValidInputData())
                {
                    return(false);
                }
                string ActResult = "";
                _item = GetObject();
                m_BusRules.InsertList(_item, ref ActResult);
                if (ActResult == ActionResult.Success.ToString())
                {
                    //Cho phép chọn trên lưới để fill dữ liệu xuống Vùng nhập liệu
                    m_blnAllowCurrentCellChanged = true;
                    //Thêm mới dòng này vào DataTable để phản ánh lại lên lưới
                    InsertDataTable();
                    txtID.Text = _item.Id.ToString();
                    //Tự động nhảy đến dòng mới thêm trên lưới
                    Utility.GonewRowJanus(grdList, DmucKieudmuc.Columns.Id, txtID.Text.Trim());

                    //Gán biến dòng hiện thời trên lưới
                    m_intCurrIdx = grdList.CurrentRow.Position;
                    //Quay về trạng thái cancel
                    PerformCancelAction();
                    //Hiển thị thông báo thành công
                    Utility.SetMsg(lblMsg, "Thêm mới kiểu danh mục thành công", false);
                    if (chkAutoNew.Checked)
                    {
                        cmdNew_Click(cmdNew, new EventArgs());
                    }
                    else
                    {
                        //Tự động Focus vào nút Sửa
                        cmdNew.Focus();
                    }
                }
                else if (ActResult == ActionResult.ExistedRecord.ToString())
                {
                    Utility.SetMsg(lblMsg, "Mã kiểu danh mục đã được sử dụng. Đề nghị bạn nhập mã khác!", true);
                    txtMa.Focus();
                    return(false);
                }
                else if (ActResult == ActionResult.Exception.ToString())
                {
                    Utility.ShowMsg("Lỗi khi thực hiện thêm mới kiểu danh mục\n" + ActResult, "Thông báo");
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                Utility.ShowMsg(ex.Message);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Tách tham số đầu vào thành các phần khác nhau
 /// </summary>
 void AnalyzeArguments(string p_strArgs)
 {
     try
     {
         string[] arrValues = p_strArgs.Split('|');
         m_strListType = arrValues[0];
         if (arrValues.Length > 1)
         {
             grdList.RootTable.Columns["VIET_TAT"].Caption = arrValues[1];
             lblViettat.Text = arrValues[1];
         }
         DmucKieudmuc objKieuDMUC = m_BusRules.GetKieuDanhMuc(m_strListType);
         m_strListName = objKieuDMUC == null ? "Chưa khai báo loại danh mục chung" : objKieuDMUC.TenLoai;
         this.Text     = m_strListName;
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Insert một bản ghi vào bảng Danh mục dùng chung
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public void InsertList(DmucKieudmuc obj,  ref string ActResult)
 {
     try
     {
         ActionResult _act = isExistedRecord(obj.MaLoai);
         if (_act == ActionResult.ExistedRecord || _act == ActionResult.Exception)
         {
             ActResult = _act.ToString();
             return;
         }
         obj.IsNew = true;
         obj.Save();
         obj.Id =Utility.Int32Dbnull( DmucKieudmuc.CreateQuery().GetMax(DmucKieudmuc.IdColumn.ColumnName),0);
         ActResult = ActionResult.Success.ToString();
     }
     catch
     {
         ActResult = ActionResult.Exception.ToString();
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Insert một bản ghi vào bảng Danh mục dùng chung
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public void InsertList(DmucKieudmuc obj, ref string ActResult)
 {
     try
     {
         ActionResult _act = isExistedRecord(obj.MaLoai);
         if (_act == ActionResult.ExistedRecord || _act == ActionResult.Exception)
         {
             ActResult = _act.ToString();
             return;
         }
         obj.IsNew = true;
         obj.Save();
         obj.Id    = Utility.Int32Dbnull(DmucKieudmuc.CreateQuery().GetMax(DmucKieudmuc.IdColumn.ColumnName), 0);
         ActResult = ActionResult.Success.ToString();
     }
     catch
     {
         ActResult = ActionResult.Exception.ToString();
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Update một bản ghi vào bảng Danh mục dùng chung
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public void UpdateList(DmucKieudmuc obj, string strOldCode,  ref string ActResult)
 {
     try
     {
         ActionResult _act = isExistedRecord4Update(obj.MaLoai, strOldCode);
         if (_act == ActionResult.ExistedRecord || _act == ActionResult.Exception)
         {
             ActResult = _act.ToString();
             return;
         }
         int record = new Update(DmucKieudmuc.Schema)
             .Set(DmucKieudmuc.Columns.MaLoai).EqualTo(obj.MaLoai)
             .Set(DmucKieudmuc.Columns.TenLoai).EqualTo(obj.TenLoai)
             .Set(DmucKieudmuc.Columns.MotaThem).EqualTo(obj.MotaThem)
             .Set(DmucKieudmuc.Columns.TrangThai).EqualTo(obj.TrangThai)
             .Set(DmucKieudmuc.Columns.NgaySua).EqualTo(obj.NgaySua)
             .Set(DmucKieudmuc.Columns.NguoiSua).EqualTo(obj.NguoiSua)
             .Where(DmucKieudmuc.Columns.Id).IsEqualTo(obj.Id).Execute();
         if (record > 0)
         {
             //Update trong bảng danh mục
             new Update(DmucChung.Schema).Set(DmucChung.Columns.Loai).EqualTo(obj.MaLoai)
                 .Where(DmucChung.Columns.Loai).IsEqualTo(strOldCode).Execute();
             ActResult = ActionResult.Success.ToString();
         }
         else
             ActResult = ActionResult.Error.ToString();
     }
     catch
     {
         ActResult = ActionResult.Exception.ToString();
     }
 }
Esempio n. 8
0
        public void Insert(string MaLoai,string TenLoai,byte TrangThai,string MotaThem,string NguoiTao,DateTime NgayTao,string NguoiSua,DateTime? NgaySua)
        {
            DmucKieudmuc item = new DmucKieudmuc();

            item.MaLoai = MaLoai;

            item.TenLoai = TenLoai;

            item.TrangThai = TrangThai;

            item.MotaThem = MotaThem;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NguoiSua = NguoiSua;

            item.NgaySua = NgaySua;

            item.Save(UserName);
        }
Esempio n. 9
0
        public void Update(int Id,string MaLoai,string TenLoai,byte TrangThai,string MotaThem,string NguoiTao,DateTime NgayTao,string NguoiSua,DateTime? NgaySua)
        {
            DmucKieudmuc item = new DmucKieudmuc();
            item.MarkOld();
            item.IsLoaded = true;

            item.Id = Id;

            item.MaLoai = MaLoai;

            item.TenLoai = TenLoai;

            item.TrangThai = TrangThai;

            item.MotaThem = MotaThem;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NguoiSua = NguoiSua;

            item.NgaySua = NgaySua;

            item.Save(UserName);
        }
Esempio n. 10
0
 public ActionResult isExistedRecord4Update(string MaMoi, string MaCu)
 {
     try
     {
         DmucKieudmucCollection v_obj = new DmucKieudmucController().FetchByQuery(DmucKieudmuc.CreateQuery().AddWhere(DmucKieudmuc.Columns.MaLoai, Comparison.NotEquals, MaCu));
         List <DmucKieudmuc>    q     = (from p in v_obj
                                         where p.MaLoai == MaMoi
                                         select p).ToList <DmucKieudmuc>();
         if (q.Count() > 0)
         {
             return(ActionResult.ExistedRecord);
         }
         return(ActionResult.Success);
     }
     catch
     {
         return(ActionResult.Exception);
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Thực hiện thêm mới dữ liệu
        /// </summary>
        private bool PerformInserAct()
        {
            try
            {
                //Kiem tra su hop le cua du lieu
                if (!IsValidInputData()) return false;
                string ActResult = "";
                 _item=GetObject();
                m_BusRules.InsertList(_item, ref ActResult);
                if (ActResult == ActionResult.Success.ToString())
                {
                    //Cho phép chọn trên lưới để fill dữ liệu xuống Vùng nhập liệu
                    m_blnAllowCurrentCellChanged = true;
                    //Thêm mới dòng này vào DataTable để phản ánh lại lên lưới
                    InsertDataTable();
                    txtID.Text = _item.Id.ToString();
                    //Tự động nhảy đến dòng mới thêm trên lưới
                    Utility.GonewRowJanus(grdList, DmucKieudmuc.Columns.Id, txtID.Text.Trim());

                    //Gán biến dòng hiện thời trên lưới
                    m_intCurrIdx = grdList.CurrentRow.Position;
                    //Quay về trạng thái cancel
                    PerformCancelAction();
                    //Hiển thị thông báo thành công
                    Utility.SetMsg(lblMsg, "Thêm mới kiểu danh mục thành công", false);
                    if (chkAutoNew.Checked)
                        cmdNew_Click(cmdNew, new EventArgs());
                    else
                    {
                        //Tự động Focus vào nút Sửa
                        cmdNew.Focus();
                    }
                }
                else if (ActResult == ActionResult.ExistedRecord.ToString())
                {
                    Utility.SetMsg(lblMsg, "Mã kiểu danh mục đã được sử dụng. Đề nghị bạn nhập mã khác!", true);
                    txtMa.Focus();
                    return false;
                }
                else if (ActResult == ActionResult.Exception.ToString())
                {

                    Utility.ShowMsg("Lỗi khi thực hiện thêm mới kiểu danh mục\n" + ActResult, "Thông báo");
                    return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
                Utility.ShowMsg(ex.Message);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Đóng gói dữ liệu vào DataTable để gửi lên Webservice xử lý
        /// </summary>
        /// <returns></returns>
        private DmucKieudmuc GetObject()
        {
            try
            {

                DmucKieudmuc obj = new DmucKieudmuc();
                if (m_enAct == action.Update) obj.Id =Utility.Int32Dbnull( txtID.Text,0);
                obj.MaLoai = Utility.DoTrim(txtMa.Text);
                obj.TenLoai = Utility.DoTrim(txtTen.Text);

                obj.TrangThai = Convert.ToByte(chkTrangthai.Checked ? 1 : 0);
                obj.MotaThem = Utility.DoTrim(txtMotathem.Text);
                if (m_enAct == action.Update)
                {
                    obj.NguoiSua = globalVariables.UserName;
                    obj.NgaySua = globalVariables.SysDate;
                }
                else
                {
                obj.NguoiTao = globalVariables.UserName;
                obj.NgayTao = globalVariables.SysDate;
                }
                return obj;

            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi xảy ra khi đóng gói dữ liệu vào DataTable để gửi lên Webservice\n" + ex.Message, "Thông báo");
                return null;
            }
        }