예제 #1
0
 private void btnActivate_Click(object sender, EventArgs e)
 {
     try
     {
         Guid gid = new Guid(txtPassword.Text);
         DemoSecurityDataSet dsDemo = new DemoSecurityDataSet();
         dsDemo.ActiveMachine.Merge(DataHelper.GetTableData(dsDemo.ActiveMachine, "Where SerialCode = '" + txtPassword.Text + "'").Tables[0]);
         if (dsDemo.ActiveMachine.Rows.Count > 0)
         {
             MessageBox.Show("Serial number is already used", "Invalid Serial", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         DataRow dr = dsDemo.ActiveMachine.NewRow();
         dr["IID"]           = Guid.NewGuid();
         dr["Processor"]     = PSerial;
         dr["Matherboard"]   = MBSerial;
         dr["ActiveMachine"] = System.Net.Dns.GetHostName();
         dr["SerialCode"]    = txtPassword.Text;
         dsDemo.ActiveMachine.Rows.Add(dr);
         DataHelper.UpdateData(dsDemo.ActiveMachine);
         _Cancel = true;
         this.Dispose();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Serial number is not correct", "Invalid Serial", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ErrorFound())
            {
                return;
            }

            DataRow dr = dsCompany.CompanyInfo.NewRow();

            dr["IID"]     = Guid.NewGuid();
            dr["Name"]    = txtCompanyName.Text;
            dr["Address"] = txtAddress.Text;
            dr["Phone"]   = txtPhone.Text;
            if (_Photo != null)
            {
                System.IO.FileStream file = new System.IO.FileStream(_Photo, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
                byte[] image1             = new byte[file.Length];
                file.Read(image1, 0, Convert.ToInt32(file.Length));
                dr["Logo"] = image1;
            }
            dsCompany.CompanyInfo.Rows.Add(dr);
            DataHelper.UpdateData(dsCompany.CompanyInfo);
            DemoSecurityDataSet dsSecurity = new DemoSecurityDataSet();
            DataRow             drs        = dsSecurity.SecurityCheck.NewRow();

            drs                = dsSecurity.SecurityCheck.NewRow();
            drs["IID"]         = Guid.NewGuid();
            drs["MachineID"]   = "";
            drs["SetupDate"]   = DateTime.Now;
            drs["EndDate"]     = DateTime.Now.AddDays(15);
            drs["Active"]      = false;
            drs["AccessTime"]  = DateTime.Now;
            drs["AccessLimit"] = 30;
            drs["IsDemo"]      = true;
            dsSecurity.SecurityCheck.Rows.Add(drs);
            DataHelper.UpdateData(dsSecurity.SecurityCheck);

            MessageBox.Show("Company Setup Successfully", "Company Setup", MessageBoxButtons.OK, MessageBoxIcon.Information);
            _cancel = false;
            this.Dispose();
        }