Ejemplo n.º 1
0
        private Boolean ktdequyParent(string CommonTypeId1, string CommonId1, string parentSelect)
        {
            DataTable dt = commonCodeBLL.GetChildren(CommonTypeId1, CommonId1);

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if (parentSelect == (dr["CommonTypeId"].ToString() + "," + dr["CommonId"].ToString()))
                    {
                        kt = 1;
                    }
                    CommonTypeId = dr["CommonTypeId"].ToString();
                    CommonId2    = dr["CommonId"].ToString();
                    ktdequyParent(CommonTypeId, CommonId2, parentSelect);
                }
                //if (kt == 1)
                //    return false;
            }
            if (kt == 1)
            {
                return(false);
            }
            else
            {
                return(true);
            }
            kt = 0;
        }
Ejemplo n.º 2
0
        private void dgvResult_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                string commonTypeId = dgvResult.Rows[e.RowIndex].Cells[1].Value.ToString();
                string commonId     = dgvResult.Rows[e.RowIndex].Cells[2].Value.ToString();
                objTempId = commonId;
                CommonCode ctId = new CommonCode();
                ctId = objBLL.GetCommonCodeById(commonTypeId, commonId);

                if (e.ColumnIndex == 6)
                {
                    if (ctId.CanDelete == "1")
                    {
                        if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("Delete01"),
                                                                             Common.clsLanguages.GetResource("Information"),
                                                                             Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                             Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                        {
                            DataTable tb = new DataTable();
                            tb = objBLL.GetChildren(commonTypeId, commonId);
                            if (tb == null || tb.Rows.Count == 0)
                            {
                                CommonType cmt = new CommonType();
                                cmt = objBLL.GetTableColumnByCommonTypeId(commonTypeId);
                                if (cmt != null && cmt.TableColumUser.ToString() != null)
                                {
                                    if (cmt.TableColumUser.ToString() != "")
                                    {
                                        string[] lines2 = Regex.Split(cmt.TableColumUser.ToString(), ",");
                                        string   table  = lines2[0];
                                        string   column = lines2[1];
                                        Boolean  c      = objBLL.CheckUser(table, column, commonId);
                                        if (c == true)
                                        {
                                            int Xoa = objBLL.Detele(commonTypeId, commonId);
                                            // xóa thành côg

                                            if (Xoa == 1)
                                            {
                                                dgvResult.Rows.RemoveAt(e.RowIndex);
                                                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("DeleteSuccess"),
                                                                                                 Common.clsLanguages.GetResource("Information"),
                                                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                                                lblTB.Text  = "...";
                                                lblTB1.Text = "...";
                                                //đánh lại stt
                                                int RecPerPage = int.Parse(ConfigurationManager.AppSettings["MaxRecordDesk"]);
                                                for (int i = 0; i < dgvResult.Rows.Count; i++)
                                                {
                                                    dgvResult.Rows[i].Cells[0].Value = ((CurPage - 1) * RecPerPage + (i + 1)).ToString();
                                                }
                                            }
                                        }
                                        else
                                        {
                                            CustomMessageBox.MessageBox.ShowCustomMessageBox(clsLanguages.GetResource("Đang được sử dụng, không thể xóa"),// đang được sử dụng
                                                                                             Common.clsLanguages.GetResource("Information"),
                                                                                             Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                                             Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                                        }
                                    }
                                    else
                                    {
                                        int Xoa = objBLL.Detele(commonTypeId, commonId);
                                        // xóa thành côg

                                        if (Xoa == 1)
                                        {
                                            dgvResult.Rows.RemoveAt(e.RowIndex);
                                            CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("DeleteSuccess"),
                                                                                             Common.clsLanguages.GetResource("Information"),
                                                                                             Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                                             Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                                            lblTB.Text  = "...";
                                            lblTB1.Text = "...";
                                            //đánh lại stt
                                            int RecPerPage = int.Parse(ConfigurationManager.AppSettings["MaxRecordDesk"]);
                                            for (int i = 0; i < dgvResult.Rows.Count; i++)
                                            {
                                                dgvResult.Rows[i].Cells[0].Value = ((CurPage - 1) * RecPerPage + (i + 1)).ToString();
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    CustomMessageBox.MessageBox.ShowCustomMessageBox("Không thể xóa, vì đang được sử dụng",    // đang được sử dụng
                                                                                     Common.clsLanguages.GetResource("Information"),
                                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                                }
                            }

                            else
                            {
                                CustomMessageBox.MessageBox.ShowCustomMessageBox("Có chứa phần tử con, không thể xóa",// đang được sử dụng
                                                                                 Common.clsLanguages.GetResource("Information"),
                                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                            }
                        }
                    }
                    else
                    {
                        CustomMessageBox.MessageBox.ShowCustomMessageBox(clsLanguages.GetResource("NoDelete"),
                                                                         Common.clsLanguages.GetResource("Information"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                    }
                }
                else
                {
                    if (ctId != null)
                    {
                        cbCommonTypeId.SelectedValue = ctId.CommonTypeId;
                        tbCommonId.Text        = string.IsNullOrEmpty(ctId.CommonId) ? "" : ctId.CommonId;
                        cbParent.SelectedValue = string.IsNullOrEmpty(ctId.ParentId) ? "" : (ctId.CommonTypeId + "," + ctId.ParentId);
                        tbNumValue1.Text       = string.IsNullOrEmpty(ctId.NumValue1) ? "" : ctId.NumValue1;
                        tbNumValue2.Text       = string.IsNullOrEmpty(ctId.NumValue2) ? "" : ctId.NumValue2;
                        tbStrValue1.Text       = string.IsNullOrEmpty(ctId.StrValue1) ? "" : ctId.StrValue1;
                        tbStrValue2.Text       = string.IsNullOrEmpty(ctId.StrValue2) ? "" : ctId.StrValue2;
                    }
                }
            }
        }