Ejemplo n.º 1
0
        bool CreateNewCompanyConfiguration()
        {
            if (mPkValue == 0)
            {
                DataSet ldtst = new DataSet(); int lnewcompid = 1;

                ldtst.ReadXml(Application.StartupPath + @"\Conn.xml");
                if (ldtst.Tables.Count > 0)
                {
                    lnewcompid = Convert.ToInt32(ldtst.Tables[0].Compute("max([compid])", string.Empty)) + 1;
                    ldtst.Tables[0].Rows.Add(lnewcompid, txtComapanyName.Text, lnewcompid);
                }
                else
                {
                    ldtst.Tables.Add("configruation");
                    ldtst.Tables[0].Columns.Add("compid", typeof(string));
                    ldtst.Tables[0].Columns.Add("compname", typeof(string));
                    ldtst.Tables[0].Columns.Add("dbname", typeof(string));
                    ldtst.Tables[0].Rows.Add(lnewcompid, txtComapanyName.Text, lnewcompid);
                }
                ldtst.WriteXml(Application.StartupPath + @"\Conn.xml");
                System.IO.File.Copy(Application.StartupPath + @"\cab\dump.sdf", Application.StartupPath + @"\cab\" + lnewcompid + ".sdf");
                AppFun.SetAppConnection(lnewcompid.ToString());

                //var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                //var connectionStringsSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
                //string _connString = connectionStringsSection.ConnectionStrings["Inv_DatabaseEntities"].ConnectionString;
                //EntityConnectionStringBuilder ecsb = new EntityConnectionStringBuilder(_connString);
                dbx = new Inv_DatabaseEntities(AppInit.AppInfo.EntityConnectionString);
                return(true);
            }
            return(true);
        }
Ejemplo n.º 2
0
        void CompanySelectionDo()
        {
            string ldbname = string.Empty;
            string lcompid = string.Empty;

            if (gridCompany.SelectedRowsCount == 0 && gridCompany.FocusedRowHandle < 0)
            {
                return;
            }
            if (gridCompany.SelectedRowsCount == 0)
            {
                gridCompany.FocusedRowHandle = 0;
                lcompid = gridCompany.GetFocusedRowCellValue("compid").ToString();
            }
            else if (gridCompany.FocusedRowHandle < 0)
            {
                gridCompany.FocusedRowHandle = 0;
                lcompid = gridCompany.GetFocusedRowCellValue("compid").ToString();
            }
            else
            {
                lcompid = gridCompany.GetFocusedRowCellValue("compid").ToString();
            }
            if (lcompid.Length > 0)
            {
                DataTable ltb = (DataTable)xGridCompany.DataSource;
                foreach (DataRow dr in ltb.Select(" compid = '" + lcompid + "'"))
                {
                    AppInit.CompanyInfo.CompanyName = dr["compname"].ToString();
                    AppInit.CompanyInfo.DbName      = dr["dbname"].ToString();
                }
                this.DialogResult = DialogResult.OK;

                this.Close();
            }
            else
            {
                this.DialogResult          = DialogResult.Cancel;
                AppInit.CompanyInfo.DbName = "";
            }

            if (AppInit.CompanyInfo.DbName.Length != 0)
            {
                //var config = new ConfigurationSettings.ap

                AppFun.SetAppConnection(AppInit.CompanyInfo.DbName);
            }
        }