Esempio n. 1
0
        private bool Insert()
        {
            new_entity = new DIC_INFORMATIC();
            new_entity.InformaticCode = txt_INFORMATIC_CODE.Text;
            new_entity.InformaticName = txt_INFORMATIC_NAME.Text;
            new_entity.Description    = txt_DESCRIPTION.Text;
            //new_entity.IsManager = chk_IS_MANAGER.Checked;
            new_entity.Active = true;
            ENT_RETURN validate = LOGIC_CHECK.Check_Data(new_entity);

            if (validate.Status)
            {
                DAO_DIC_INFORMATIC.Add(new_entity);
                if (parent != null)
                {
                    parent.dg_DATA.DataSource = DAO_DIC_INFORMATIC.Get_Data();
                }
            }
            else
            {
                XtraMessageBox.Show(validate.Message, "Lỗi..!!!");
                return(false);
            }
            return(true);
        }
 public void RaiseUpdatedEventHander(DIC_INFORMATIC Item)
 {
     if (this.Updated != null)
     {
         this.Updated(this, Item);
     }
 }
 private void RaiseSuccessEventHander(DIC_INFORMATIC item)
 {
     if (this.Success != null)
     {
         this.Success(this, item);
     }
 }
Esempio n. 4
0
 public override void Change()
 {
     if (!(MyRule.Get(MyLogin.RoleId, "bbiInformatic") != "OK"))
     {
         if (MyRule.AllowAccess)
         {
             DIC_INFORMATIC dICINFORMATIC = new DIC_INFORMATIC();
             object         cellValue     = base.GetCellValue(this.m_RowClickEventArgs.RowIndex, "InformaticCode");
             if (cellValue != null)
             {
                 base.SetWaitDialogCaption("Đang kiểm tra dữ liệu....");
                 if (!(dICINFORMATIC.Get(cellValue.ToString()) != "OK"))
                 {
                     this.DoHide();
                     xfmInformaticAdd _xfmInformaticAdd = new xfmInformaticAdd(Actions.Update, dICINFORMATIC);
                     _xfmInformaticAdd.Updated += new xfmInformaticAdd.UpdatedEventHander(this.frm_Updated);
                     _xfmInformaticAdd.Added   += new xfmInformaticAdd.AddedEventHander(this.frm_Added);
                     _xfmInformaticAdd.ShowDialog();
                 }
                 else
                 {
                     this.DoHide();
                     XtraMessageBox.Show("Dữ liệu không tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
         }
         else
         {
             MyRule.Notify();
         }
     }
 }
        protected override string uc_Update()
        {
            string str;

            if (MyRule.Get(MyLogin.RoleId, "bbiInformatic") != "OK")
            {
                str = "";
            }
            else if (MyRule.AllowEdit)
            {
                // SYS_LOG.Insert("Danh Mục Tin Học", "Cập Nhật", this.txtID.Text);
                base.SetWaitDialogCaption("Đang cập nhật dữ liệu...");
                DIC_INFORMATIC dICINFORMATIC = new DIC_INFORMATIC(this.txtID.Text, this.txtNAME.Text, this.txtDescription.Text, this.chxUse.Checked);
                string         str1          = dICINFORMATIC.Update();
                if (str1 == "OK")
                {
                    this.RaiseSuccessEventHander(dICINFORMATIC);
                }
                if (str1 != "OK")
                {
                    XtraMessageBox.Show(str1, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                this.DoHide();
                str = str1;
            }
            else
            {
                MyRule.Notify();
                str = "";
            }
            return(str);
        }
Esempio n. 6
0
        public static ENT_RETURN Check_Data(DIC_INFORMATIC e)
        {
            ENT_RETURN ret     = new ENT_RETURN();
            string     err_msg = string.Empty;

            // BEGIN CHECK
            if (Is_Empty_String(e.InformaticName))
            {
                err_msg += GLOBAL.err_code["E010"];
            }
            if (Is_Over_MaxLength(e.InformaticName, 100))
            {
                err_msg += GLOBAL.err_code["E011"];
            }
            if (Is_Over_MaxLength(e.Description, 200))
            {
                err_msg += GLOBAL.err_code["E003"];
            }
            // END CHECK
            if (err_msg != string.Empty)
            {
                ret.Message = err_msg;
                ret.Status  = false;
            }
            return(ret);
        }
Esempio n. 7
0
 private void RaiseItemSelectedEventHander(DIC_INFORMATIC item)
 {
     if (this.ItemSelected != null)
     {
         this.ItemSelected(this, item);
     }
 }
        protected override void Add()
        {
            base.Add();
            DIC_INFORMATIC dICINFORMATIC = new DIC_INFORMATIC();

            this.txtID.Text = dICINFORMATIC.NewID();
            this.txtNAME.Focus();
        }
Esempio n. 9
0
 private void frm_EDIT_Load(object sender, EventArgs e)
 {
     old_entity = new DIC_INFORMATIC();
     old_entity.InformaticCode = CODE;
     old_entity = DAO_DIC_INFORMATIC.Select_Record(old_entity);
     txt_INFORMATIC_CODE.Text = old_entity.InformaticCode;
     txt_INFORMATIC_NAME.Text = old_entity.InformaticName;
     txt_DESCRIPTION.Text     = old_entity.Description;
 }
Esempio n. 10
0
        public xfmInformaticAdd(Actions Action)
        {
            this.InitializeComponent();
            this.Init();
            this.ucAdd.Status = Action;
            DIC_INFORMATIC dICINFORMATIC = new DIC_INFORMATIC();

            this.ucAdd.SetData(dICINFORMATIC.NewID());
            this.Text = "Thêm";
        }
Esempio n. 11
0
        private void UpdateRow(DIC_INFORMATIC item, RowClickEventArgs e)
        {
            AdvBandedGridView advBandedGridView = this.gbList;
            int rowIndex = e.RowIndex;

            advBandedGridView.SetRowCellValue(rowIndex, "Active", item.Active);
            advBandedGridView.SetRowCellValue(rowIndex, "InformaticCode", item.InformaticCode);
            advBandedGridView.SetRowCellValue(rowIndex, "InformaticName", item.InformaticName);
            advBandedGridView.SetRowCellValue(rowIndex, "Description", item.Description);
            advBandedGridView.UpdateCurrentRow();
        }
Esempio n. 12
0
 public void SetData(DIC_INFORMATIC item)
 {
     this.txtID.Text = item.InformaticCode;
     //  SYS_LOG.Insert("Danh Mục Tin Học", "Xem", this.txtID.Text);
     if (this.m_Status == Actions.Update)
     {
         this.txtID.Properties.ReadOnly = true;
     }
     this.txtNAME.Text        = item.InformaticName;
     this.txtDescription.Text = item.Description;
     this.chxUse.Checked      = item.Active;
 }
Esempio n. 13
0
        private void AddRow(DIC_INFORMATIC Item)
        {
            AdvBandedGridView advBandedGridView = this.gbList;
            int focusedRowHandle = advBandedGridView.FocusedRowHandle;

            advBandedGridView.AddNewRow();
            focusedRowHandle = advBandedGridView.FocusedRowHandle;
            advBandedGridView.SetRowCellValue(focusedRowHandle, "Active", Item.Active);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "InformaticCode", Item.InformaticCode);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "InformaticName", Item.InformaticName);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "Description", Item.Description);
            advBandedGridView.UpdateCurrentRow();
        }
Esempio n. 14
0
        protected override string uc_Delete()
        {
            DIC_INFORMATIC dICINFORMATIC = new DIC_INFORMATIC()
            {
                InformaticCode = this.txtID.Text
            };
            string str = dICINFORMATIC.Delete();

            if (str == "OK")
            {
                this.RaiseSuccessEventHander(dICINFORMATIC);
            }
            return(str);
        }
Esempio n. 15
0
 public xfmInformaticAdd(Actions Action, DIC_INFORMATIC Item)
 {
     this.InitializeComponent();
     this.Init();
     this.ucAdd.Status = Action;
     if (Action == Actions.Update)
     {
         this.ucAdd.SetData(Item);
         this.Text = "Cập nhật";
     }
     else if (Action == Actions.Delete)
     {
         this.ucAdd.SetData(Item.InformaticCode);
     }
 }
Esempio n. 16
0
 private void ucAdd_Success(object sender, DIC_INFORMATIC Item)
 {
     if (this.ucAdd.Status == Actions.Add)
     {
         this.RaiseAddedEventHander(Item);
     }
     else if (this.ucAdd.Status == Actions.Update)
     {
         this.RaiseUpdatedEventHander(Item);
     }
     if (this.ucAdd.IsClose == CloseOrNew.Close)
     {
         base.Close();
     }
     this.ucAdd.Clear();
 }
Esempio n. 17
0
        public static DIC_INFORMATIC Select_Record(DIC_INFORMATIC clsDIC_INFORMATICPara)
        {
            DIC_INFORMATIC clsDIC_INFORMATIC = new DIC_INFORMATIC();
            SqlConnection  connection        = DAO_BASE.Get_Connection();
            string         selectStatement
                = "SELECT "
                  + "     [InformaticCode] "
                  + "    ,[InformaticName] "
                  + "    ,[Description] "
                  + "    ,[Active] "
                  + "FROM "
                  + "     [DIC_INFORMATIC] "
                  + "WHERE "
                  + "     [InformaticCode] = @InformaticCode "
                  + "";
            SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

            selectCommand.CommandType = CommandType.Text;
            selectCommand.Parameters.AddWithValue("@InformaticCode", clsDIC_INFORMATICPara.InformaticCode);
            try
            {
                connection.Open();
                SqlDataReader reader
                    = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    clsDIC_INFORMATIC.InformaticCode = System.Convert.ToString(reader["InformaticCode"]);
                    clsDIC_INFORMATIC.InformaticName = reader["InformaticName"] is DBNull ? null : reader["InformaticName"].ToString();
                    clsDIC_INFORMATIC.Description    = reader["Description"] is DBNull ? null : reader["Description"].ToString();
                    clsDIC_INFORMATIC.Active         = reader["Active"] is DBNull ? null : (Boolean?)reader["Active"];
                }
                else
                {
                    clsDIC_INFORMATIC = null;
                }
                reader.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(clsDIC_INFORMATIC);
        }
Esempio n. 18
0
        protected override void txtID_KeyDown(object sender, KeyEventArgs e)
        {
            TextEdit textEdit = (TextEdit)sender;

            if (e.KeyCode == Keys.Return | e.KeyCode == Keys.Tab)
            {
                DIC_INFORMATIC dICINFORMATIC = new DIC_INFORMATIC();
                if (this.m_Status == Actions.Add)
                {
                    if (dICINFORMATIC.Exist(textEdit.Text))
                    {
                        this.Err.SetError(textEdit, "Mã đã tồn tại.");
                        textEdit.Focus();
                    }
                }
            }
        }
Esempio n. 19
0
        private void btn_SAVE_Click(object sender, EventArgs e)
        {
            new_entity = new DIC_INFORMATIC();


            new_entity.InformaticCode = txt_INFORMATIC_CODE.Text;
            new_entity.InformaticName = txt_INFORMATIC_NAME.Text;
            new_entity.Description    = txt_DESCRIPTION.Text;
            new_entity.Active         = old_entity.Active;
            ENT_RETURN validate = LOGIC_CHECK.Check_Data(new_entity);

            if (validate.Status)
            {
                DAO_DIC_INFORMATIC.Update(old_entity, new_entity);
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                XtraMessageBox.Show(validate.Message, "Lỗi..!!!");
            }
        }
Esempio n. 20
0
        public override void ReLoad()
        {
            base.SetWaitDialogCaption("Đang nạp dữ liệu...");
            DIC_INFORMATIC dICINFORMATIC = new DIC_INFORMATIC();

            this.gcList.DataSource = dICINFORMATIC.GetList();
            base.SetWaitDialogCaption("Đang nạp cấu hình...");
            this.List_Init(this.gbList);
            base.SetWaitDialogCaption("Nạp quyền sử dụng...");
            MyRule.Get(MyLogin.RoleId, "bbiInformatic");
            if (!MyRule.AllowPrint)
            {
                this.ucToolBar.bbiPrint.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiInformatic");
            if (!MyRule.AllowExport)
            {
                this.ucToolBar.bbiExport.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiInformatic");
            if (!MyRule.AllowAdd)
            {
                this.ucToolBar.bbiAdd.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiInformatic");
            if (!MyRule.AllowDelete)
            {
                this.ucToolBar.bbiDelete.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiInformatic");
            if (!MyRule.AllowEdit)
            {
                this.ucToolBar.bbiEdit.Visibility = BarItemVisibility.Never;
            }
            base.SetWaitDialogCaption("Đã xong...");
            this.DoHide();
        }
Esempio n. 21
0
        public override void Delete()
        {
            object cellValue;

            if (!(MyRule.Get(MyLogin.RoleId, "bbiInformatic") != "OK"))
            {
                if (MyRule.AllowDelete)
                {
                    if (ClsOption.System2.IsQuestion)
                    {
                        if (XtraMessageBox.Show("Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            return;
                        }
                    }
                    base.SetWaitDialogCaption("Đang xóa...");
                    string            str  = "";
                    bool              flag = false;
                    AdvBandedGridView advBandedGridView = this.gbList;
                    int[]             selectedRows      = advBandedGridView.GetSelectedRows();
                    DIC_INFORMATIC    dICINFORMATIC     = new DIC_INFORMATIC();
                    for (int i = (int)selectedRows.Length; i > 0; i--)
                    {
                        flag      = true;
                        cellValue = base.GetCellValue(selectedRows[i - 1], "InformaticCode");
                        if (cellValue != null)
                        {
                            //   SYS_LOG.Insert("Danh Mục Tin Học", "Xoá", cellValue.ToString());
                            str = dICINFORMATIC.Delete(cellValue.ToString());
                            if (str == "OK")
                            {
                                advBandedGridView.DeleteRow(selectedRows[i - 1]);
                            }
                            else if (str != "OK")
                            {
                                MessageBox.Show(string.Concat("Thông tin không được xóa\n", str), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                            }
                        }
                    }
                    this.DoHide();
                    if (!flag)
                    {
                        if (advBandedGridView.DataSource != null)
                        {
                            RowClickEventArgs rowClickEventArg = new RowClickEventArgs((advBandedGridView == null ? -1 : advBandedGridView.FocusedRowHandle), (advBandedGridView.FocusedColumn == null ? -1 : advBandedGridView.FocusedColumn.ColumnHandle), (advBandedGridView.FocusedColumn == null ? "" : advBandedGridView.FocusedColumn.FieldName));
                            this.m_RowClickEventArgs = rowClickEventArg;
                            cellValue = null;
                            cellValue = base.GetCellValue(rowClickEventArg.RowIndex, "InformaticCode");
                            if (cellValue != null)
                            {
                                //  SYS_LOG.Insert("Danh Mục Tin Học", "Xoá", cellValue.ToString());
                                base.SetWaitDialogCaption("Đang xóa...");
                                str = dICINFORMATIC.Delete(cellValue.ToString());
                                if (str == "OK")
                                {
                                    advBandedGridView.DeleteRow(rowClickEventArg.RowIndex);
                                }
                                else if (str != "OK")
                                {
                                    MessageBox.Show(string.Concat("Thông tin không được xóa\n", str), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                                }
                                this.DoHide();
                            }
                        }
                    }
                }
                else
                {
                    MyRule.Notify();
                }
            }
        }
Esempio n. 22
0
 private void frm_Updated(object sender, DIC_INFORMATIC Item)
 {
     this.UpdateRow(Item, this.m_RowClickEventArgs);
 }
Esempio n. 23
0
 private void frm_Added(object sender, DIC_INFORMATIC e)
 {
     this.AddRow(e);
 }
Esempio n. 24
0
        public static bool Update(DIC_INFORMATIC oldDIC_INFORMATIC,
                                  DIC_INFORMATIC newDIC_INFORMATIC)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        updateStatement
                = "UPDATE "
                  + "     [DIC_INFORMATIC] "
                  + "SET "
                  + "     [InformaticCode] = @NewInformaticCode "
                  + "    ,[InformaticName] = @NewInformaticName "
                  + "    ,[Description] = @NewDescription "
                  + "    ,[Active] = @NewActive "
                  + "WHERE "
                  + "     [InformaticCode] = @OldInformaticCode "
                  + " AND ((@OldInformaticName IS NULL AND [InformaticName] IS NULL) OR [InformaticName] = @OldInformaticName) "
                  + " AND ((@OldDescription IS NULL AND [Description] IS NULL) OR [Description] = @OldDescription) "
                  + " AND ((@OldActive IS NULL AND [Active] IS NULL) OR [Active] = @OldActive) "
                  + "";
            SqlCommand updateCommand = new SqlCommand(updateStatement, connection);

            updateCommand.CommandType = CommandType.Text;
            updateCommand.Parameters.AddWithValue("@NewInformaticCode", newDIC_INFORMATIC.InformaticCode);
            if (newDIC_INFORMATIC.InformaticName != null)
            {
                updateCommand.Parameters.AddWithValue("@NewInformaticName", newDIC_INFORMATIC.InformaticName);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewInformaticName", DBNull.Value);
            }
            if (newDIC_INFORMATIC.Description != null)
            {
                updateCommand.Parameters.AddWithValue("@NewDescription", newDIC_INFORMATIC.Description);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewDescription", DBNull.Value);
            }
            if (newDIC_INFORMATIC.Active.HasValue == true)
            {
                updateCommand.Parameters.AddWithValue("@NewActive", newDIC_INFORMATIC.Active);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewActive", DBNull.Value);
            }
            updateCommand.Parameters.AddWithValue("@OldInformaticCode", oldDIC_INFORMATIC.InformaticCode);
            if (oldDIC_INFORMATIC.InformaticName != null)
            {
                updateCommand.Parameters.AddWithValue("@OldInformaticName", oldDIC_INFORMATIC.InformaticName);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OldInformaticName", DBNull.Value);
            }
            if (oldDIC_INFORMATIC.Description != null)
            {
                updateCommand.Parameters.AddWithValue("@OldDescription", oldDIC_INFORMATIC.Description);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value);
            }
            if (oldDIC_INFORMATIC.Active.HasValue == true)
            {
                updateCommand.Parameters.AddWithValue("@OldActive", oldDIC_INFORMATIC.Active);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OldActive", DBNull.Value);
            }
            try
            {
                connection.Open();
                int count = updateCommand.ExecuteNonQuery();
                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
Esempio n. 25
0
        public static bool Delete(DIC_INFORMATIC clsDIC_INFORMATIC)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        deleteStatement
                = "DELETE FROM "
                  + "     [DIC_INFORMATIC] "
                  + "WHERE "
                  + "     [InformaticCode] = @OldInformaticCode "
                  + " AND ((@OldInformaticName IS NULL AND [InformaticName] IS NULL) OR [InformaticName] = @OldInformaticName) "
                  + " AND ((@OldDescription IS NULL AND [Description] IS NULL) OR [Description] = @OldDescription) "
                  + " AND ((@OldActive IS NULL AND [Active] IS NULL) OR [Active] = @OldActive) "
                  + "";
            SqlCommand deleteCommand = new SqlCommand(deleteStatement, connection);

            deleteCommand.CommandType = CommandType.Text;
            deleteCommand.Parameters.AddWithValue("@OldInformaticCode", clsDIC_INFORMATIC.InformaticCode);
            if (clsDIC_INFORMATIC.InformaticName != null)
            {
                deleteCommand.Parameters.AddWithValue("@OldInformaticName", clsDIC_INFORMATIC.InformaticName);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldInformaticName", DBNull.Value);
            }
            if (clsDIC_INFORMATIC.Description != null)
            {
                deleteCommand.Parameters.AddWithValue("@OldDescription", clsDIC_INFORMATIC.Description);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value);
            }
            if (clsDIC_INFORMATIC.Active.HasValue == true)
            {
                deleteCommand.Parameters.AddWithValue("@OldActive", clsDIC_INFORMATIC.Active);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldActive", DBNull.Value);
            }
            try
            {
                connection.Open();
                int count = deleteCommand.ExecuteNonQuery();
                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
Esempio n. 26
0
        public static bool Add(DIC_INFORMATIC clsDIC_INFORMATIC)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        insertStatement
                = "INSERT "
                  + "     [DIC_INFORMATIC] "
                  + "     ( "
                  + "     [InformaticCode] "
                  + "    ,[InformaticName] "
                  + "    ,[Description] "
                  + "    ,[Active] "
                  + "     ) "
                  + "VALUES "
                  + "     ( "
                  + "     @InformaticCode "
                  + "    ,@InformaticName "
                  + "    ,@Description "
                  + "    ,@Active "
                  + "     ) "
                  + "";
            SqlCommand insertCommand = new SqlCommand(insertStatement, connection);

            insertCommand.CommandType = CommandType.Text;
            insertCommand.Parameters.AddWithValue("@InformaticCode", clsDIC_INFORMATIC.InformaticCode);
            if (clsDIC_INFORMATIC.InformaticName != null)
            {
                insertCommand.Parameters.AddWithValue("@InformaticName", clsDIC_INFORMATIC.InformaticName);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@InformaticName", DBNull.Value);
            }
            if (clsDIC_INFORMATIC.Description != null)
            {
                insertCommand.Parameters.AddWithValue("@Description", clsDIC_INFORMATIC.Description);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@Description", DBNull.Value);
            }
            if (clsDIC_INFORMATIC.Active.HasValue == true)
            {
                insertCommand.Parameters.AddWithValue("@Active", clsDIC_INFORMATIC.Active);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@Active", DBNull.Value);
            }
            try
            {
                connection.Open();
                int count = insertCommand.ExecuteNonQuery();
                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }