示例#1
0
        public static ENT_RETURN Check_Data(DIC_ETHNIC e)
        {
            ENT_RETURN ret     = new ENT_RETURN();
            string     err_msg = string.Empty;

            // BEGIN CHECK
            if (Is_Empty_String(e.EthnicName))
            {
                err_msg += GLOBAL.err_code["E014"];
            }
            if (Is_Over_MaxLength(e.EthnicName, 100))
            {
                err_msg += GLOBAL.err_code["E015"];
            }
            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);
        }
示例#2
0
 public void RaiseUpdatedEventHander(DIC_ETHNIC Item)
 {
     if (this.Updated != null)
     {
         this.Updated(this, Item);
     }
 }
示例#3
0
 private void RaiseSuccessEventHander(DIC_ETHNIC item)
 {
     if (this.Success != null)
     {
         this.Success(this, item);
     }
 }
示例#4
0
 private void RaiseItemSelectedEventHander(DIC_ETHNIC item)
 {
     if (this.ItemSelected != null)
     {
         this.ItemSelected(this, item);
     }
 }
示例#5
0
 public override void Change()
 {
     if (!(MyRule.Get(MyLogin.RoleId, "bbiEthnic") != "OK"))
     {
         if (MyRule.AllowAccess)
         {
             DIC_ETHNIC dICETHNIC = new DIC_ETHNIC();
             object     cellValue = base.GetCellValue(this.m_RowClickEventArgs.RowIndex, "EthnicCode");
             if (cellValue != null)
             {
                 base.SetWaitDialogCaption("Đang kiểm tra dữ liệu....");
                 if (!(dICETHNIC.Get(cellValue.ToString()) != "OK"))
                 {
                     this.DoHide();
                     xfmEthnicAdd _xfmEthnicAdd = new xfmEthnicAdd(Actions.Update, dICETHNIC);
                     _xfmEthnicAdd.Updated += new xfmEthnicAdd.UpdatedEventHander(this.frm_Updated);
                     _xfmEthnicAdd.Added   += new xfmEthnicAdd.AddedEventHander(this.frm_Added);
                     _xfmEthnicAdd.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();
         }
     }
 }
示例#6
0
        protected override string uc_Update()
        {
            string str;

            if (MyRule.Get(MyLogin.RoleId, "bbiEthnic") != "OK")
            {
                str = "";
            }
            else if (MyRule.AllowEdit)
            {
                //   SYS_LOG.Insert("Danh Mục Dân Tộc", "Cập Nhật", this.txtID.Text);
                base.SetWaitDialogCaption("Đang cập nhật dữ liệu...");
                DIC_ETHNIC dICETHNIC = new DIC_ETHNIC(this.txtID.Text, this.txtNAME.Text, this.txtDescription.Text, this.chxUse.Checked);
                string     str1      = dICETHNIC.Update();
                if (str1 == "OK")
                {
                    this.RaiseSuccessEventHander(dICETHNIC);
                }
                if (str1 != "OK")
                {
                    XtraMessageBox.Show(str1, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                this.DoHide();
                str = str1;
            }
            else
            {
                MyRule.Notify();
                str = "";
            }
            return(str);
        }
示例#7
0
        protected override void Add()
        {
            base.Add();
            DIC_ETHNIC dICETHNIC = new DIC_ETHNIC();

            this.txtID.Text = dICETHNIC.NewID();
            this.txtNAME.Focus();
        }
示例#8
0
 private void frm_EDIT_Load(object sender, EventArgs e)
 {
     old_entity            = new DIC_ETHNIC();
     old_entity.EthnicCode = CODE;
     old_entity            = DAO_DIC_ETHNIC.Select_Record(old_entity);
     txt_ETHNIC_CODE.Text  = old_entity.EthnicCode;
     txt_ETHNIC_NAME.Text  = old_entity.EthnicName;
     txt_DESCRIPTION.Text  = old_entity.Description;
 }
示例#9
0
        public xfmEthnicAdd(Actions Action)
        {
            this.InitializeComponent();
            this.Init();
            this.ucAdd.Status = Action;
            DIC_ETHNIC dICETHNIC = new DIC_ETHNIC();

            this.ucAdd.SetData(dICETHNIC.NewID());
            this.Text = "Thêm";
        }
示例#10
0
        private void UpdateRow(DIC_ETHNIC item, RowClickEventArgs e)
        {
            AdvBandedGridView advBandedGridView = this.gbList;
            int rowIndex = e.RowIndex;

            advBandedGridView.SetRowCellValue(rowIndex, "Active", item.Active);
            advBandedGridView.SetRowCellValue(rowIndex, "EthnicCode", item.EthnicCode);
            advBandedGridView.SetRowCellValue(rowIndex, "EthnicName", item.EthnicName);
            advBandedGridView.SetRowCellValue(rowIndex, "Description", item.Description);
            advBandedGridView.UpdateCurrentRow();
        }
示例#11
0
 public void SetData(DIC_ETHNIC item)
 {
     this.txtID.Text = item.EthnicCode;
     //    SYS_LOG.Insert("Danh Mục Dân Tộc", "Xem", this.txtID.Text);
     if (this.m_Status == Actions.Update)
     {
         this.txtID.Properties.ReadOnly = true;
     }
     this.txtNAME.Text        = item.EthnicName;
     this.txtDescription.Text = item.Description;
     this.chxUse.Checked      = item.Active;
 }
示例#12
0
        private void AddRow(DIC_ETHNIC Item)
        {
            AdvBandedGridView advBandedGridView = this.gbList;
            int focusedRowHandle = advBandedGridView.FocusedRowHandle;

            advBandedGridView.AddNewRow();
            focusedRowHandle = advBandedGridView.FocusedRowHandle;
            advBandedGridView.SetRowCellValue(focusedRowHandle, "Active", Item.Active);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "EthnicCode", Item.EthnicCode);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "EthnicName", Item.EthnicName);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "Description", Item.Description);
            advBandedGridView.UpdateCurrentRow();
        }
示例#13
0
        protected override string uc_Delete()
        {
            DIC_ETHNIC dICETHNIC = new DIC_ETHNIC()
            {
                EthnicCode = this.txtID.Text
            };
            string str = dICETHNIC.Delete();

            if (str == "OK")
            {
                this.RaiseSuccessEventHander(dICETHNIC);
            }
            return(str);
        }
示例#14
0
 public xfmEthnicAdd(Actions Action, DIC_ETHNIC 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.EthnicCode);
     }
 }
示例#15
0
 private void ucAdd_Success(object sender, DIC_ETHNIC 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();
 }
示例#16
0
        public static DIC_ETHNIC Select_Record(DIC_ETHNIC clsDIC_ETHNICPara)
        {
            DIC_ETHNIC    clsDIC_ETHNIC = new DIC_ETHNIC();
            SqlConnection connection    = DAO_BASE.Get_Connection();
            string        selectStatement
                = "SELECT "
                  + "     [EthnicCode] "
                  + "    ,[EthnicName] "
                  + "    ,[Description] "
                  + "    ,[Active] "
                  + "FROM "
                  + "     [DIC_ETHNIC] "
                  + "WHERE "
                  + "     [EthnicCode] = @EthnicCode "
                  + "";
            SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

            selectCommand.CommandType = CommandType.Text;
            selectCommand.Parameters.AddWithValue("@EthnicCode", clsDIC_ETHNICPara.EthnicCode);
            try
            {
                connection.Open();
                SqlDataReader reader
                    = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    clsDIC_ETHNIC.EthnicCode  = System.Convert.ToString(reader["EthnicCode"]);
                    clsDIC_ETHNIC.EthnicName  = reader["EthnicName"] is DBNull ? null : reader["EthnicName"].ToString();
                    clsDIC_ETHNIC.Description = reader["Description"] is DBNull ? null : reader["Description"].ToString();
                    clsDIC_ETHNIC.Active      = reader["Active"] is DBNull ? null : (Boolean?)reader["Active"];
                }
                else
                {
                    clsDIC_ETHNIC = null;
                }
                reader.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(clsDIC_ETHNIC);
        }
示例#17
0
        protected override void txtID_KeyDown(object sender, KeyEventArgs e)
        {
            TextEdit textEdit = (TextEdit)sender;

            if (e.KeyCode == Keys.Return | e.KeyCode == Keys.Tab)
            {
                DIC_ETHNIC dICETHNIC = new DIC_ETHNIC();
                if (this.m_Status == Actions.Add)
                {
                    if (dICETHNIC.Exist(textEdit.Text))
                    {
                        this.Err.SetError(textEdit, "Mã đã tồn tại.");
                        textEdit.Focus();
                    }
                }
            }
        }
示例#18
0
        private void btn_SAVE_Click(object sender, EventArgs e)
        {
            new_entity             = new DIC_ETHNIC();
            new_entity.EthnicCode  = txt_ETHNIC_CODE.Text;
            new_entity.EthnicName  = txt_ETHNIC_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_ETHNIC.Update(old_entity, new_entity);
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                XtraMessageBox.Show(validate.Message, "Lỗi.!!!");
            }
        }
示例#19
0
        public override void ReLoad()
        {
            base.SetWaitDialogCaption("Đang nạp dữ liệu...");
            DIC_ETHNIC dICETHNIC = new DIC_ETHNIC();

            this.gcList.DataSource = dICETHNIC.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, "bbiEthnic");
            if (!MyRule.AllowPrint)
            {
                this.ucToolBar.bbiPrint.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiEthnic");
            if (!MyRule.AllowExport)
            {
                this.ucToolBar.bbiExport.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiEthnic");
            if (!MyRule.AllowAdd)
            {
                this.ucToolBar.bbiAdd.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiEthnic");
            if (!MyRule.AllowDelete)
            {
                this.ucToolBar.bbiDelete.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiEthnic");
            if (!MyRule.AllowEdit)
            {
                this.ucToolBar.bbiEdit.Visibility = BarItemVisibility.Never;
            }
            base.SetWaitDialogCaption("Đã xong...");
            this.DoHide();
        }
示例#20
0
        private bool Insert()
        {
            new_entity             = new DIC_ETHNIC();
            new_entity.EthnicCode  = txt_ETHNIC_CODE.Text;
            new_entity.EthnicName  = txt_ETHNIC_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_ETHNIC.Add(new_entity);
                if (parent != null)
                {
                    parent.dg_DATA.DataSource = DAO_DIC_ETHNIC.Get_Data();
                }
            }
            else
            {
                XtraMessageBox.Show(validate.Message, "Lỗi.!!!"); return(false);
            }
            return(true);
        }
示例#21
0
 private void frm_Updated(object sender, DIC_ETHNIC Item)
 {
     this.UpdateRow(Item, this.m_RowClickEventArgs);
 }
示例#22
0
 private void frm_Added(object sender, DIC_ETHNIC e)
 {
     this.AddRow(e);
 }
示例#23
0
        public static bool Add(DIC_ETHNIC clsDIC_ETHNIC)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        insertStatement
                = "INSERT "
                  + "     [DIC_ETHNIC] "
                  + "     ( "
                  + "     [EthnicCode] "
                  + "    ,[EthnicName] "
                  + "    ,[Description] "
                  + "    ,[Active] "
                  + "     ) "
                  + "VALUES "
                  + "     ( "
                  + "     @EthnicCode "
                  + "    ,@EthnicName "
                  + "    ,@Description "
                  + "    ,@Active "
                  + "     ) "
                  + "";
            SqlCommand insertCommand = new SqlCommand(insertStatement, connection);

            insertCommand.CommandType = CommandType.Text;
            insertCommand.Parameters.AddWithValue("@EthnicCode", clsDIC_ETHNIC.EthnicCode);
            if (clsDIC_ETHNIC.EthnicName != null)
            {
                insertCommand.Parameters.AddWithValue("@EthnicName", clsDIC_ETHNIC.EthnicName);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@EthnicName", DBNull.Value);
            }
            if (clsDIC_ETHNIC.Description != null)
            {
                insertCommand.Parameters.AddWithValue("@Description", clsDIC_ETHNIC.Description);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@Description", DBNull.Value);
            }
            if (clsDIC_ETHNIC.Active.HasValue == true)
            {
                insertCommand.Parameters.AddWithValue("@Active", clsDIC_ETHNIC.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();
            }
        }
示例#24
0
        public static bool Delete(DIC_ETHNIC clsDIC_ETHNIC)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        deleteStatement
                = "DELETE FROM "
                  + "     [DIC_ETHNIC] "
                  + "WHERE "
                  + "     [EthnicCode] = @OldEthnicCode "
                  + " AND ((@OldEthnicName IS NULL AND [EthnicName] IS NULL) OR [EthnicName] = @OldEthnicName) "
                  + " 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("@OldEthnicCode", clsDIC_ETHNIC.EthnicCode);
            if (clsDIC_ETHNIC.EthnicName != null)
            {
                deleteCommand.Parameters.AddWithValue("@OldEthnicName", clsDIC_ETHNIC.EthnicName);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldEthnicName", DBNull.Value);
            }
            if (clsDIC_ETHNIC.Description != null)
            {
                deleteCommand.Parameters.AddWithValue("@OldDescription", clsDIC_ETHNIC.Description);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value);
            }
            if (clsDIC_ETHNIC.Active.HasValue == true)
            {
                deleteCommand.Parameters.AddWithValue("@OldActive", clsDIC_ETHNIC.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();
            }
        }
示例#25
0
        public override void Delete()
        {
            object cellValue;

            if (!(MyRule.Get(MyLogin.RoleId, "bbiEthnic") != "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_ETHNIC        dICETHNIC         = new DIC_ETHNIC();
                    for (int i = (int)selectedRows.Length; i > 0; i--)
                    {
                        flag      = true;
                        cellValue = base.GetCellValue(selectedRows[i - 1], "EthnicCode");
                        if (cellValue != null)
                        {
                            //    SYS_LOG.Insert("Danh Mục Dân Tộc", "Xoá", cellValue.ToString());
                            str = dICETHNIC.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, "EthnicCode");
                            if (cellValue != null)
                            {
                                //  SYS_LOG.Insert("Danh Mục Dân Tộc", "Xoá", cellValue.ToString());
                                base.SetWaitDialogCaption("Đang xóa...");
                                str = dICETHNIC.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();
                }
            }
        }
示例#26
0
        public static bool Update(DIC_ETHNIC oldDIC_ETHNIC,
                                  DIC_ETHNIC newDIC_ETHNIC)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        updateStatement
                = "UPDATE "
                  + "     [DIC_ETHNIC] "
                  + "SET "
                  + "     [EthnicCode] = @NewEthnicCode "
                  + "    ,[EthnicName] = @NewEthnicName "
                  + "    ,[Description] = @NewDescription "
                  + "    ,[Active] = @NewActive "
                  + "WHERE "
                  + "     [EthnicCode] = @OldEthnicCode "
                  + " AND ((@OldEthnicName IS NULL AND [EthnicName] IS NULL) OR [EthnicName] = @OldEthnicName) "
                  + " 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("@NewEthnicCode", newDIC_ETHNIC.EthnicCode);
            if (newDIC_ETHNIC.EthnicName != null)
            {
                updateCommand.Parameters.AddWithValue("@NewEthnicName", newDIC_ETHNIC.EthnicName);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewEthnicName", DBNull.Value);
            }
            if (newDIC_ETHNIC.Description != null)
            {
                updateCommand.Parameters.AddWithValue("@NewDescription", newDIC_ETHNIC.Description);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewDescription", DBNull.Value);
            }
            if (newDIC_ETHNIC.Active.HasValue == true)
            {
                updateCommand.Parameters.AddWithValue("@NewActive", newDIC_ETHNIC.Active);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewActive", DBNull.Value);
            }
            updateCommand.Parameters.AddWithValue("@OldEthnicCode", oldDIC_ETHNIC.EthnicCode);
            if (oldDIC_ETHNIC.EthnicName != null)
            {
                updateCommand.Parameters.AddWithValue("@OldEthnicName", oldDIC_ETHNIC.EthnicName);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OldEthnicName", DBNull.Value);
            }
            if (oldDIC_ETHNIC.Description != null)
            {
                updateCommand.Parameters.AddWithValue("@OldDescription", oldDIC_ETHNIC.Description);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value);
            }
            if (oldDIC_ETHNIC.Active.HasValue == true)
            {
                updateCommand.Parameters.AddWithValue("@OldActive", oldDIC_ETHNIC.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();
            }
        }