Esempio n. 1
0
        private void FxCancel()
        {
            ImgLogo.Image = null;

            lFileLogo = "";

            TxtName.Text        = "";
            TxtDescription.Text = "";
            TxtExecutable.Text  = "";

            ChkEnabled.Checked = false;

            TxtName.Enabled        = false;
            TxtDescription.Enabled = false;
            TxtExecutable.Enabled  = false;

            ChkEnabled.Enabled = false;

            CmdLogo.Enabled = true;
            CmdSave.Enabled = false;

            if (lModuleId == 0)
            {
                Text += " - Adicionar";

                TxtName.Enabled        = true;
                TxtDescription.Enabled = true;
                TxtExecutable.Enabled  = true;

                ChkEnabled.Checked = true;

                CmdSave.Enabled = true;

                TxtName.Focus();
            }
            else
            {
                Text += " - Modificar";

                DataTable ObjDt = ClsSqlAdministrator.Fx_sel_tblModule_detail(lModuleId);

                if (ObjDt != null)
                {
                    if (ObjDt.Rows.Count > 0)
                    {
                        TxtName.Text        = ObjDt.Rows[0][0].ToString();
                        TxtDescription.Text = ObjDt.Rows[0][1].ToString();
                        TxtExecutable.Text  = ObjDt.Rows[0][2].ToString();

                        ChkEnabled.Checked = ClsFunctions.FxConvertStringToBool(ObjDt.Rows[0][3].ToString());

                        Bitmap ObjLogo;

                        try
                        {
                            ObjLogo = ClsSqlAdministrator.Fx_sel_tblModuleLogo(lModuleId);
                        }
                        catch
                        {
                            ObjLogo = null;
                        }

                        if (ObjLogo != null)
                        {
                            lFileLogo = ClsVariables.gPathTemp + "Img" + ClsFunctions.FxRandomNumber().ToString() + ".png";

                            if (File.Exists(lFileLogo))
                            {
                                ClsFunctions.FxDeleteFile(lFileLogo);
                            }

                            ObjLogo.Save(lFileLogo);

                            ObjLogo.Dispose();

                            ImgLogo.Image = Bitmap.FromFile(lFileLogo);
                        }

                        TxtName.Enabled        = true;
                        TxtDescription.Enabled = true;
                        TxtExecutable.Enabled  = true;

                        ChkEnabled.Enabled = true;

                        CmdSave.Enabled = true;

                        TxtName.Focus();
                    }
                }
            }
        }