示例#1
0
 /// <summary>
 /// 打开指定的窗口
 /// </summary>
 /// <param name="winForm"></param>
 public void OpenForm(XtraForm winForm)
 {
     if (!FormAlreadyOpen(winForm.GetType()))
     {
         winForm.MdiParent = this;
         winForm.Show();
     }
 }
 public void DisposeAllButThis(XtraForm form)
 {
     foreach (XtraForm frm in this.MdiChildren)
     {
         if (frm.GetType() == form.GetType() &&
             frm != form)
         {
             frm.Dispose();
             frm.Close();
         }
     }
 }
示例#3
0
 // Hàm tự động insert nếu không tồn tại record form trong db
 public static bool AutoInsertIfNonExists(XtraForm form)
 {
     try
     {
         string sql = "select name_form from fw_show_form where name_form='" + form.GetType().FullName + "'";
         DatabaseFB db = DABase.getDatabase();
         DbCommand check = db.GetSQLStringCommand(sql);
         if (db.ExecuteScalar(check) == null)
         {
             db = DABase.getDatabase();
             long form_id = db.GetID(HelpGen.G_FW_ID);
             sql = "insert into fw_show_form values('" + form_id + "','" + form.GetType().FullName + "','" + form.Text + "','Y')";
             DbCommand insert = db.GetSQLStringCommand(sql);
             db.ExecuteNonQuery(insert);
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
示例#4
0
        private void ShowForm(XtraForm form)
        {
            foreach (Form formFilho in this.MdiChildren)
            {
                if (formFilho.GetType() == form.GetType())
                {
                    formFilho.Focus();
                    return;
                }
            }

            form.IsMdiContainer = false;
            form.MdiParent      = this;
            form.Show();
        }
示例#5
0
 /// <summary>
 /// Kiem tra 1 form co phai la public form
 /// trong toan bo he thong dua vao danh sach public form
 /// va loai form
 /// </summary>
 /// <param name="form"></param>
 /// <returns></returns>
 public static bool CanShowForm(XtraForm form)
 {
     if (form != null)
     {
         if (form is IPublicForm) return true;
         string formName = form.GetType().FullName;
         return CanShowForm(formName);
     }
     else
     {
         return false;
     }
 }
示例#6
0
        // Hàm add checkbox vào form
        private void AddCheckbox(XtraForm mainform, XtraForm form)
        {
            int w = form.Width;
            int h = form.Height;
            form.Size = new System.Drawing.Size(w, h + 30);
            form.SuspendLayout();

            // Khởi tạo checkbox for add
            DevExpress.XtraEditors.CheckEdit checkEdit1 = new DevExpress.XtraEditors.CheckEdit();
            checkEdit1.Location = new System.Drawing.Point(13, h - 30);//subheader
            checkEdit1.Name = "_" + form.GetType().FullName;
            checkEdit1.Properties.Caption = "Hiện màn hình này ở các lần sau.";
            checkEdit1.Size = new System.Drawing.Size(w, 19);
            checkEdit1.TabIndex = 4;
            checkEdit1.Checked = true;
            checkEdit1.Click += new System.EventHandler(Checkbox_Click);
            form.Controls.Add(checkEdit1);

            form.ResumeLayout(false);
            form.PerformLayout();
        }
示例#7
0
 // Hàm kiểm tra xem có được show form hay không
 public bool IsShow(XtraForm mainform, XtraForm form)
 {
     bool flag = false;
     //if (LoadCheckbox(mainform.GetType().FullName) == "Y")
     if (LoadCheckbox(form.GetType().FullName) == "Y")
     {
         AddCheckbox(mainform, form);
         flag = true;
     }
     return flag;
 }
示例#8
0
 public UserForm(XtraForm mainform)
 {
     if (File.Exists(UserFormHelp.xml))
     {
         try
         {
             _Refresh();
             if (LoadCheckbox(mainform.GetType().FullName) == "")
             {
                 if(UserFormHelp.AutoInsertIfNonExists(mainform) == false)
                     return;
                 Update_XML();
             }
         }
         catch
         {
             File.Delete(UserFormHelp.xml);
             if (UserFormHelp.AutoInsertIfNonExists(mainform) == false)
                 return;
             UserFormHelp.Create_XML_NULL();
         }
     }
     else
     {
         if (UserFormHelp.AutoInsertIfNonExists(mainform) == false)
             return;
         UserFormHelp.Create_XML_NULL();
     }
 }
示例#9
0
 public FormItem(string bbiName, XtraForm frmIn)
 {
     this._bbiName = bbiName;
     this._cForm   = frmIn;
     this._fType   = frmIn.GetType();
 }
示例#10
0
        public static void pl_wrapper(ref XtraForm form, IFormat isFormat, IPermission isPermision)
        {
            ProtocolForm standard = new ProtocolForm(form);
            if (isPermision != null)
                standard.applyActions.Add(new ProtocolVN.Framework.Win.ApplyPermissionAction(form.GetType().ToString()));
            if (isFormat != null)
                standard.applyActions.Add(new ProtocolVN.Framework.Win.ApplyFormatAction());

            //PHUOCNC : Thất bại có thể rơi vào chức năng khác
            //          Nhưng hiện tại chắc chắn thất bại chỉ do phân quyền
            if (standard.wrapperForm() == false)
            {
                form.Close();
                form = ApplyPermissionAction.getPermissionFormFail();
            }
            else
            {

            }
        }
示例#11
0
        /// <summary>
        /// Método para llamar al formulario de Edición
        /// </summary>
        public void Editar()
        {
            if (permisoEditar)
            {
                System.Reflection.Assembly myDllAssembly = System.Reflection.Assembly.LoadFile(@"" + PerfilShow.Proyecto);
                Type t = myDllAssembly.GetType(PerfilShow.Formulario);

                object o = Activator.CreateInstance(t);

                if (GvGeneral.GetFocusedDataSourceRowIndex() > -1)
                {
                    try
                    {
                        int hver = GvGeneral.GetFocusedDataSourceRowIndex();
                        Seleccion = dsGeneral.Tables[0].Rows[GvGeneral.GetFocusedDataSourceRowIndex()][PerfilShow.Llave].ToString();
                        //DescripcionSeleccion = dsGeneral.Tables[0].Rows[GvGeneral.GetFocusedDataSourceRowIndex()][PerfilShow.CampoNombre].ToString();
                        //IdentificacionSeleccion = dsGeneral.Tables[0].Rows[GvGeneral.GetFocusedDataSourceRowIndex()][PerfilShow.CampoCodigo].ToString();


                        PropertyInfo desdeShow = o.GetType().GetProperty("DesdeMenu");
                        desdeShow.SetValue(o, DesdeMenu, null);

                        PropertyInfo modo = o.GetType().GetProperty("Modo");
                        modo.SetValue(o, "E", null);

                        if (OpGet)
                        {
                            PropertyInfo Get = o.GetType().GetProperty("OpcionGet");
                            Get.SetValue(o, OpcionGet, null);
                        }

                        PropertyInfo perfil = o.GetType().GetProperty("PerfilAct");
                        perfil.SetValue(o, PerfilShow, null);

                        PropertyInfo codigo = o.GetType().GetProperty("ID");
                        codigo.SetValue(o, Seleccion, null);

                        PropertyInfo db = o.GetType().GetProperty("Database");
                        db.SetValue(o, database, null);

                        if (PasarUsuario)
                        {
                            PropertyInfo Get = o.GetType().GetProperty("Usuario");
                            Get.SetValue(o, Usuario, null);
                        }

                        if (PerfilShow.Formulario.Equals("GLUserControls.FrmGetCodeName"))
                        {
                            PropertyInfo ponerCeros = o.GetType().GetProperty("PonerCeros");
                            ponerCeros.SetValue(o, PonerCeros, null);
                        }
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show(ex.Message, GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    XtraForm frm = (XtraForm)o;
                    frm.ShowDialog();

                    if (frm.DialogResult == DialogResult.OK && DesdeMenu)
                    {
                        LlenarDataSet();
                        LlenarGrilla();
                    }

                    if (frm.DialogResult == DialogResult.OK && !DesdeMenu)
                    {
                        Seleccion    = frm.GetType().GetProperty("ID").GetValue(frm, null).ToString();
                        DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                }
                else
                {
                    XtraMessageBox.Show("Debe seleccionar un registro", GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                }
            }
            else
            {
                XtraMessageBox.Show("El usuario " + Usuario + " no tiene permiso para realizar esta operación.", GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#12
0
        /// <summary>
        /// Método para llamar al formulario de Adición
        /// </summary>
        public void Añadir()
        {
            if (permisoAdicionar)
            {
                object o = null;
                try
                {
                    Assembly myDllAssembly = Assembly.LoadFile(@"" + PerfilShow.Proyecto);
                    Type     t             = myDllAssembly.GetType(PerfilShow.Formulario);

                    if (t != null)
                    {
                        o = Activator.CreateInstance(t);
                    }
                    else
                    {
                        o = Assembly.GetEntryAssembly().CreateInstance(PerfilShow.Formulario);
                    }

                    PropertyInfo desdeShow = o.GetType().GetProperty("DesdeMenu");
                    desdeShow.SetValue(o, DesdeMenu, null);

                    PropertyInfo modo = o.GetType().GetProperty("Modo");
                    modo.SetValue(o, "N", null);

                    if (OpGet)
                    {
                        PropertyInfo Get = o.GetType().GetProperty("OpcionGet");
                        Get.SetValue(o, OpcionGet, null);
                    }

                    PropertyInfo perfil = o.GetType().GetProperty("PerfilAct");
                    perfil.SetValue(o, PerfilShow, null);

                    PropertyInfo db = o.GetType().GetProperty("Database");
                    db.SetValue(o, database, null);

                    if (PasarUsuario)
                    {
                        PropertyInfo Get = o.GetType().GetProperty("Usuario");
                        Get.SetValue(o, Usuario, null);
                    }

                    if (PerfilShow.Formulario.Equals("GLUserControls.FrmGetCodeName"))
                    {
                        PropertyInfo ponerCeros = o.GetType().GetProperty("PonerCeros");
                        ponerCeros.SetValue(o, PonerCeros, null);
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message, GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                string camp = "";
                camp = PerfilShow.Llave + "," + camp.Vector2Cadena(",", PerfilShow.Campos).Replace(PerfilShow.Llave + ",", "");
                String    cad   = String.Format("SELECT DISTINCT TOP(1) {0} FROM {1} {2} WHERE delmrk = 1 {3} ORDER BY {4} DESC", camp, PerfilShow.Tabla, Relacion, Complemento, PerfilShow.Llave);
                DataTable dt    = DataBase.ExecuteQueryDataTable(cad, "datos", CommandType.Text, null, ConexionDB.getInstancia().Conexion(database, null));
                DataSet   dsUlt = new DataSet();
                dsUlt.Tables.Add(dt);

                XtraForm frm = (XtraForm)o;
                frm.ShowDialog();

                if (frm.DialogResult == DialogResult.OK && DesdeMenu)
                {
                    Seleccion = frm.GetType().GetProperty("ID").GetValue(frm, null).ToString();
                    int resto = 0;

                    if (dsUlt.Tables[0].Rows.Count != 0)
                    {
                        resto = Convert.ToInt32(Seleccion) - Convert.ToInt32(dsUlt.Tables[0].Rows[0][PerfilShow.Llave]);
                    }
                    else
                    {
                        resto = Convert.ToInt32(Seleccion) - 0;
                    }

                    cad = String.Format("SELECT TOP({0}) {1} FROM {2} {3} WHERE delmrk = 1 {4} ORDER BY {5} DESC", resto, camp, PerfilShow.Tabla, Relacion, Complemento, PerfilShow.Llave);
                    DataTable dt1 = DataBase.ExecuteQueryDataTable(cad, "datos", CommandType.Text, null, ConexionDB.getInstancia().Conexion(database, null));
                    dsGeneral.Tables.Clear();
                    dsGeneral.Tables.Add(dt1);

                    LlenarGrilla();
                }

                if (frm.DialogResult == DialogResult.OK && !DesdeMenu)
                {
                    Seleccion    = frm.GetType().GetProperty("ID").GetValue(frm, null).ToString();
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
            else
            {
                XtraMessageBox.Show("El usuario " + Usuario + " no tiene permiso para realizar esta operación.", GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }