public async Task <List <actdetails> > PostJetSA100CustomersAct(actdetails emp) { List <actdetails> EmpInfo = new List <actdetails>(); string Baseurl = "http://api.jetsystems.xyz/api/JetSA100CustomersAct"; //"http://*****:*****@"data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=" + GlobalConstants.commondocsCOMPANYDBpath + "; integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"; DataAccess.JetSA100Act objJetSA100Act = new DataAccess.JetSA100Act(); objJetSA100Act.SysName = emp.SysName; objJetSA100Act.SysNameLoggedOn = DateTime.UtcNow; context.JetSA100Act.Add(objJetSA100Act); int z = context.SaveChanges(); } } return(EmpInfo); } }
//vs2019test private void Activation_Load(object sender, EventArgs e) { lblSysname.Text = Environment.MachineName; using (var context = new Database1Entities()) { ((System.Data.SqlClient.SqlConnection)context.Database.Connection).ConnectionString = @"data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=" + GlobalConstants.commondocsCOMPANYDBpath + "; integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"; SqlConnection CN = new SqlConnection(); CN.ConnectionString = ((System.Data.SqlClient.SqlConnection)context.Database.Connection).ConnectionString; DataTable dt = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter("select Pk_Client_Id as Reference, Title +' '+ FName+' '+ LName as Name, UTR from client ORDER BY UTR", CN); sda.Fill(dt); //apicall string machineName = Environment.MachineName; //List<actdetails> objmycustomers = new List<actdetails>(); actdetails objact = new actdetails(); objact.SysName = machineName; int count = 0; SqlDataAdapter ada = new SqlDataAdapter("select * from JetSA100Act", CN); CN.Open(); DataTable dtact = new DataTable(); ada.Fill(dtact); textBox1.Text = dtact.Rows[0]["ActivationKey"].ToString(); lblRecordSize.Text = dtact.Rows[0]["RecordSize"].ToString(); lblSubmissionsCount.Text = dtact.Rows[0]["SubCount"].ToString(); CN.Close(); } }
private async void Main_Load(object sender, EventArgs e) { int CommonDocumentsFolder = 0x002e; SHGetFolderPath(IntPtr.Zero, CommonDocumentsFolder, IntPtr.Zero, 0x0000, sb); GlobalConstants.commondocspath = sb.ToString(); GlobalConstants.commondocsCOMPANYpath = GlobalConstants.commondocspath + "\\ACCCALCIDB"; GlobalConstants.commondocsCOMPANYDBpath = GlobalConstants.commondocspath + "\\ACCCALCIDB\\Database1.mdf"; bool exists = System.IO.Directory.Exists(GlobalConstants.commondocsCOMPANYpath); if (!exists) { System.IO.Directory.CreateDirectory(GlobalConstants.commondocsCOMPANYpath); File.WriteAllBytes(GlobalConstants.commondocsCOMPANYDBpath, Properties.Resources.Database1); File.WriteAllText(GlobalConstants.commondocsCOMPANYpath + "\\postdata.xml", Properties.Resources.postdata); File.WriteAllText(GlobalConstants.commondocsCOMPANYpath + "\\MTR_v2_0.xsd", Properties.Resources.MTR_v2_0); File.WriteAllText(GlobalConstants.commondocsCOMPANYpath + "\\FBI.xml", Properties.Resources.FBI); File.WriteAllText(GlobalConstants.commondocsCOMPANYpath + "\\Ack.xml", Properties.Resources.Ack); } txtSearch.Focus(); dataGridView1.ClearSelection(); using (var context = new Database1Entities()) { //((System.Data.SqlClient.SqlConnection)context.Database.Connection).ConnectionString = @"data source=(LocalDB)\MSSQLLocalDB;attachdbfilename="+ GlobalConstants.commondocsCOMPANYpath + "\\Database1.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"; //((System.Data.SqlClient.SqlConnection)context.Database.Connection).ConnectionString = @"data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=F:\GPONE20180218\SAONE\SAONE\bin\Debug\Resources\Database1.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"; ((System.Data.SqlClient.SqlConnection)context.Database.Connection).ConnectionString = @"data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=" + GlobalConstants.commondocsCOMPANYDBpath + "; integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"; SqlConnection CN = new SqlConnection(); CN.ConnectionString = ((System.Data.SqlClient.SqlConnection)context.Database.Connection).ConnectionString; dataGridView1.AutoGenerateColumns = false; DataTable dt = new DataTable(); foreach (DataGridViewColumn col in dataGridView1.Columns) { dt.Columns.Add(col.Name); col.DataPropertyName = col.Name; } SqlDataAdapter sda = new SqlDataAdapter("select Pk_Client_Id as Reference, Title +' '+ FName+' '+ LName as Name, UTR from client ORDER BY UTR", CN); sda.Fill(dt); dataGridView1.DataSource = dt; if (dataGridView1.Columns.Count == 3) { addcolumns(); } //apicall string machineName = Environment.MachineName; //List<actdetails> objmycustomers = new List<actdetails>(); actdetails objact = new actdetails(); objact.SysName = machineName; int count = 0; SqlCommand cmd = new SqlCommand("select COUNT(*) from JetSA100Act ", CN); CN.Open(); count = (Int32)cmd.ExecuteScalar(); CN.Close(); if (count == 0) { await PostJetSA100CustomersAct(objact); } } // if (dataGridView1.Columns.Count==4) //{ // DataGridViewButtonColumn btn = new DataGridViewButtonColumn(); // dataGridView1.Columns.Add(btn); // btn.Text = "Open"; // btn.UseColumnTextForButtonValue = true; //} // string con = @"data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=" + GlobalConstants.commondocsCOMPANYDBpath + "; integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"; // updateConfigFile(con); }