Пример #1
0
        protected override string uc_Update()
        {
            string str;

            if (MyRule.Get(MyLogin.RoleId, "bbiNationality") != "OK")
            {
                str = "";
            }
            else if (MyRule.AllowEdit)
            {
                //   SYS_LOG.Insert("Danh Mục Quốc Tịch", "Cập Nhật", this.txtID.Text);
                base.SetWaitDialogCaption("Đang cập nhật dữ liệu...");
                DIC_NATIONALITY dICNATIONALITY = new DIC_NATIONALITY(this.txtID.Text, this.txtNAME.Text, this.txtDescription.Text, this.chxUse.Checked);
                string          str1           = dICNATIONALITY.Update();
                if (str1 == "OK")
                {
                    this.RaiseSuccessEventHander(dICNATIONALITY);
                }
                if (str1 != "OK")
                {
                    XtraMessageBox.Show(str1, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                this.DoHide();
                str = str1;
            }
            else
            {
                MyRule.Notify();
                str = "";
            }
            return(str);
        }
Пример #2
0
 private void RaiseItemSelectedEventHander(DIC_NATIONALITY item)
 {
     if (this.ItemSelected != null)
     {
         this.ItemSelected(this, item);
     }
 }
Пример #3
0
 public void RaiseUpdatedEventHander(DIC_NATIONALITY Item)
 {
     if (this.Updated != null)
     {
         this.Updated(this, Item);
     }
 }
Пример #4
0
 public override void Change()
 {
     if (!(MyRule.Get(MyLogin.RoleId, "bbiNationality") != "OK"))
     {
         if (MyRule.AllowAccess)
         {
             DIC_NATIONALITY dICNATIONALITY = new DIC_NATIONALITY();
             object          cellValue      = base.GetCellValue(this.m_RowClickEventArgs.RowIndex, "NationalityCode");
             if (cellValue != null)
             {
                 base.SetWaitDialogCaption("Đang kiểm tra dữ liệu....");
                 if (!(dICNATIONALITY.Get(cellValue.ToString()) != "OK"))
                 {
                     this.DoHide();
                     xfmNationalityAdd _xfmNationalityAdd = new xfmNationalityAdd(Actions.Update, dICNATIONALITY);
                     _xfmNationalityAdd.Updated += new xfmNationalityAdd.UpdatedEventHander(this.frm_Updated);
                     _xfmNationalityAdd.Added   += new xfmNationalityAdd.AddedEventHander(this.frm_Added);
                     _xfmNationalityAdd.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();
         }
     }
 }
Пример #5
0
        public static ENT_RETURN Check_Data(DIC_NATIONALITY e)
        {
            ENT_RETURN ret     = new ENT_RETURN();
            string     err_msg = string.Empty;

            // BEGIN CHECK
            if (Is_Empty_String(e.NationalityName))
            {
                err_msg += GLOBAL.err_code["E012"];
            }
            if (Is_Over_MaxLength(e.NationalityName, 100))
            {
                err_msg += GLOBAL.err_code["E013"];
            }
            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);
        }
Пример #6
0
 private void RaiseSuccessEventHander(DIC_NATIONALITY item)
 {
     if (this.Success != null)
     {
         this.Success(this, item);
     }
 }
Пример #7
0
        protected override void Add()
        {
            base.Add();
            DIC_NATIONALITY dICNATIONALITY = new DIC_NATIONALITY();

            this.txtID.Text = dICNATIONALITY.NewID();
            this.txtNAME.Focus();
        }
Пример #8
0
 private void frm_EDIT_Load(object sender, EventArgs e)
 {
     old_entity = new DIC_NATIONALITY();
     old_entity.NationalityCode = CODE;
     old_entity = DAO_DIC_NATIONALITY.Select_Record(old_entity);
     txt_NATIONALITY_CODE.Text = old_entity.NationalityCode;
     txt_NATIONALITY_NAME.Text = old_entity.NationalityName;
     txt_DESCRIPTION.Text      = old_entity.Description;
 }
Пример #9
0
        public xfmNationalityAdd(Actions Action)
        {
            this.InitializeComponent();
            this.Init();
            this.ucAdd.Status = Action;
            DIC_NATIONALITY dICNATIONALITY = new DIC_NATIONALITY();

            this.ucAdd.SetData(dICNATIONALITY.NewID());
            this.Text = "thêm";
        }
Пример #10
0
        private void UpdateRow(DIC_NATIONALITY item, RowClickEventArgs e)
        {
            AdvBandedGridView advBandedGridView = this.gbList;
            int rowIndex = e.RowIndex;

            advBandedGridView.SetRowCellValue(rowIndex, "Active", item.Active);
            advBandedGridView.SetRowCellValue(rowIndex, "NationalityCode", item.NationalityCode);
            advBandedGridView.SetRowCellValue(rowIndex, "NationalityName", item.NationalityName);
            advBandedGridView.SetRowCellValue(rowIndex, "Description", item.Description);
            advBandedGridView.UpdateCurrentRow();
        }
Пример #11
0
 public void SetData(DIC_NATIONALITY item)
 {
     this.txtID.Text = item.NationalityCode;
     //   SYS_LOG.Insert("Danh Mục Quốc Tịch", "Xem", this.txtID.Text);
     if (this.m_Status == Actions.Update)
     {
         this.txtID.Properties.ReadOnly = true;
     }
     this.txtNAME.Text        = item.NationalityName;
     this.txtDescription.Text = item.Description;
     this.chxUse.Checked      = item.Active;
 }
Пример #12
0
        private void AddRow(DIC_NATIONALITY Item)
        {
            AdvBandedGridView advBandedGridView = this.gbList;
            int focusedRowHandle = advBandedGridView.FocusedRowHandle;

            advBandedGridView.AddNewRow();
            focusedRowHandle = advBandedGridView.FocusedRowHandle;
            advBandedGridView.SetRowCellValue(focusedRowHandle, "Active", Item.Active);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "NationalityCode", Item.NationalityCode);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "NationalityName", Item.NationalityName);
            advBandedGridView.SetRowCellValue(focusedRowHandle, "Description", Item.Description);
            advBandedGridView.UpdateCurrentRow();
        }
Пример #13
0
        protected override string uc_Delete()
        {
            DIC_NATIONALITY dICNATIONALITY = new DIC_NATIONALITY()
            {
                NationalityCode = this.txtID.Text
            };
            string str = dICNATIONALITY.Delete();

            if (str == "OK")
            {
                this.RaiseSuccessEventHander(dICNATIONALITY);
            }
            return(str);
        }
Пример #14
0
 public xfmNationalityAdd(Actions Action, DIC_NATIONALITY 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.NationalityCode);
     }
 }
Пример #15
0
 private void ucAdd_Success(object sender, DIC_NATIONALITY 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_NATIONALITY Select_Record(DIC_NATIONALITY clsDIC_NATIONALITYPara)
        {
            DIC_NATIONALITY clsDIC_NATIONALITY = new DIC_NATIONALITY();
            SqlConnection   connection         = DAO_BASE.Get_Connection();
            string          selectStatement
                = "SELECT "
                  + "     [NationalityCode] "
                  + "    ,[NationalityName] "
                  + "    ,[Description] "
                  + "    ,[Active] "
                  + "FROM "
                  + "     [DIC_NATIONALITY] "
                  + "WHERE "
                  + "     [NationalityCode] = @NationalityCode "
                  + "";
            SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

            selectCommand.CommandType = CommandType.Text;
            selectCommand.Parameters.AddWithValue("@NationalityCode", clsDIC_NATIONALITYPara.NationalityCode);
            try
            {
                connection.Open();
                SqlDataReader reader
                    = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    clsDIC_NATIONALITY.NationalityCode = System.Convert.ToString(reader["NationalityCode"]);
                    clsDIC_NATIONALITY.NationalityName = reader["NationalityName"] is DBNull ? null : reader["NationalityName"].ToString();
                    clsDIC_NATIONALITY.Description     = reader["Description"] is DBNull ? null : reader["Description"].ToString();
                    clsDIC_NATIONALITY.Active          = reader["Active"] is DBNull ? null : (Boolean?)reader["Active"];
                }
                else
                {
                    clsDIC_NATIONALITY = null;
                }
                reader.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(clsDIC_NATIONALITY);
        }
Пример #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_NATIONALITY dICNATIONALITY = new DIC_NATIONALITY();
                if (this.m_Status == Actions.Add)
                {
                    if (dICNATIONALITY.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_NATIONALITY();
            new_entity.NationalityCode = txt_NATIONALITY_CODE.Text;
            new_entity.NationalityName = txt_NATIONALITY_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_NATIONALITY.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_NATIONALITY dICNATIONALITY = new DIC_NATIONALITY();

            this.gcList.DataSource = dICNATIONALITY.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, "bbiNationality");
            if (!MyRule.AllowPrint)
            {
                this.ucToolBar.bbiPrint.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiNationality");
            if (!MyRule.AllowExport)
            {
                this.ucToolBar.bbiExport.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiNationality");
            if (!MyRule.AllowAdd)
            {
                this.ucToolBar.bbiAdd.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiNationality");
            if (!MyRule.AllowDelete)
            {
                this.ucToolBar.bbiDelete.Visibility = BarItemVisibility.Never;
            }
            MyRule.Get(MyLogin.RoleId, "bbiNationality");
            if (!MyRule.AllowEdit)
            {
                this.ucToolBar.bbiEdit.Visibility = BarItemVisibility.Never;
            }
            base.SetWaitDialogCaption("Đã xong...");
            this.DoHide();
        }
Пример #20
0
        private bool Insert()
        {
            new_entity = new DIC_NATIONALITY();
            new_entity.NationalityCode = txt_NATIONALITY_CODE.Text;
            new_entity.NationalityName = txt_NATIONALITY_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_NATIONALITY.Add(new_entity);
                if (parent != null)
                {
                    parent.dg_DATA.DataSource = DAO_DIC_NATIONALITY.Get_Data();
                }
            }
            else
            {
                XtraMessageBox.Show(validate.Message, "Lỗi.!!!");
            }
            return(true);
        }
Пример #21
0
        public static bool Add(DIC_NATIONALITY clsDIC_NATIONALITY)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        insertStatement
                = "INSERT "
                  + "     [DIC_NATIONALITY] "
                  + "     ( "
                  + "     [NationalityCode] "
                  + "    ,[NationalityName] "
                  + "    ,[Description] "
                  + "    ,[Active] "
                  + "     ) "
                  + "VALUES "
                  + "     ( "
                  + "     @NationalityCode "
                  + "    ,@NationalityName "
                  + "    ,@Description "
                  + "    ,@Active "
                  + "     ) "
                  + "";
            SqlCommand insertCommand = new SqlCommand(insertStatement, connection);

            insertCommand.CommandType = CommandType.Text;
            insertCommand.Parameters.AddWithValue("@NationalityCode", clsDIC_NATIONALITY.NationalityCode);
            if (clsDIC_NATIONALITY.NationalityName != null)
            {
                insertCommand.Parameters.AddWithValue("@NationalityName", clsDIC_NATIONALITY.NationalityName);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@NationalityName", DBNull.Value);
            }
            if (clsDIC_NATIONALITY.Description != null)
            {
                insertCommand.Parameters.AddWithValue("@Description", clsDIC_NATIONALITY.Description);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@Description", DBNull.Value);
            }
            if (clsDIC_NATIONALITY.Active.HasValue == true)
            {
                insertCommand.Parameters.AddWithValue("@Active", clsDIC_NATIONALITY.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();
            }
        }
Пример #22
0
 private void frm_Updated(object sender, DIC_NATIONALITY Item)
 {
     this.UpdateRow(Item, this.m_RowClickEventArgs);
 }
Пример #23
0
 private void frm_Added(object sender, DIC_NATIONALITY e)
 {
     this.AddRow(e);
 }
Пример #24
0
        public static bool Delete(DIC_NATIONALITY clsDIC_NATIONALITY)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        deleteStatement
                = "DELETE FROM "
                  + "     [DIC_NATIONALITY] "
                  + "WHERE "
                  + "     [NationalityCode] = @OldNationalityCode "
                  + " AND ((@OldNationalityName IS NULL AND [NationalityName] IS NULL) OR [NationalityName] = @OldNationalityName) "
                  + " 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("@OldNationalityCode", clsDIC_NATIONALITY.NationalityCode);
            if (clsDIC_NATIONALITY.NationalityName != null)
            {
                deleteCommand.Parameters.AddWithValue("@OldNationalityName", clsDIC_NATIONALITY.NationalityName);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldNationalityName", DBNull.Value);
            }
            if (clsDIC_NATIONALITY.Description != null)
            {
                deleteCommand.Parameters.AddWithValue("@OldDescription", clsDIC_NATIONALITY.Description);
            }
            else
            {
                deleteCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value);
            }
            if (clsDIC_NATIONALITY.Active.HasValue == true)
            {
                deleteCommand.Parameters.AddWithValue("@OldActive", clsDIC_NATIONALITY.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, "bbiNationality") != "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_NATIONALITY   dICNATIONALITY    = new DIC_NATIONALITY();
                    for (int i = (int)selectedRows.Length; i > 0; i--)
                    {
                        flag      = true;
                        cellValue = base.GetCellValue(selectedRows[i - 1], "NationalityCode");
                        if (cellValue != null)
                        {
                            //  SYS_LOG.Insert("Danh Mục Quốc Tịch", "Xoá", cellValue.ToString());
                            str = dICNATIONALITY.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, "NationalityCode");
                            if (cellValue != null)
                            {
                                //  SYS_LOG.Insert("Danh Mục Quốc Tịch", "Xoá", cellValue.ToString());
                                base.SetWaitDialogCaption("Đang xóa...");
                                str = dICNATIONALITY.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_NATIONALITY oldDIC_NATIONALITY,
                                  DIC_NATIONALITY newDIC_NATIONALITY)
        {
            SqlConnection connection = DAO_BASE.Get_Connection();
            string        updateStatement
                = "UPDATE "
                  + "     [DIC_NATIONALITY] "
                  + "SET "
                  + "     [NationalityCode] = @NewNationalityCode "
                  + "    ,[NationalityName] = @NewNationalityName "
                  + "    ,[Description] = @NewDescription "
                  + "    ,[Active] = @NewActive "
                  + "WHERE "
                  + "     [NationalityCode] = @OldNationalityCode "
                  + " AND ((@OldNationalityName IS NULL AND [NationalityName] IS NULL) OR [NationalityName] = @OldNationalityName) "
                  + " 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("@NewNationalityCode", newDIC_NATIONALITY.NationalityCode);
            if (newDIC_NATIONALITY.NationalityName != null)
            {
                updateCommand.Parameters.AddWithValue("@NewNationalityName", newDIC_NATIONALITY.NationalityName);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewNationalityName", DBNull.Value);
            }
            if (newDIC_NATIONALITY.Description != null)
            {
                updateCommand.Parameters.AddWithValue("@NewDescription", newDIC_NATIONALITY.Description);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewDescription", DBNull.Value);
            }
            if (newDIC_NATIONALITY.Active.HasValue == true)
            {
                updateCommand.Parameters.AddWithValue("@NewActive", newDIC_NATIONALITY.Active);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@NewActive", DBNull.Value);
            }
            updateCommand.Parameters.AddWithValue("@OldNationalityCode", oldDIC_NATIONALITY.NationalityCode);
            if (oldDIC_NATIONALITY.NationalityName != null)
            {
                updateCommand.Parameters.AddWithValue("@OldNationalityName", oldDIC_NATIONALITY.NationalityName);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OldNationalityName", DBNull.Value);
            }
            if (oldDIC_NATIONALITY.Description != null)
            {
                updateCommand.Parameters.AddWithValue("@OldDescription", oldDIC_NATIONALITY.Description);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OldDescription", DBNull.Value);
            }
            if (oldDIC_NATIONALITY.Active.HasValue == true)
            {
                updateCommand.Parameters.AddWithValue("@OldActive", oldDIC_NATIONALITY.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();
            }
        }