Beispiel #1
0
 private void FormUpdateLicense_Load(object sender, EventArgs e)
 {
     using (LicenseDataContext _context = new LicenseDataContext())
     {
         TBL_LICENSE license = (from l in _context.TBL_LICENSEs
                                where l.ACCOUNT_NO == ControlLicense.LICENSE_NUMBER
                                select l).FirstOrDefault();
         if (license != null)
         {
             LICENSE_ID            = license.LICENSE_ID;
             txtLicenseNumber.Text = license.ACCOUNT_NO;
             txtAccountName.Text   = license.ACCOUNT_NAME;
             txtPhone.Text         = license.PHONE;
             txtContactName.Text   = license.CONTACT_NAME;
             txtPhone.Text         = license.PHONE;
             txtProvince.Text      = license.PROVINCE_NAME;
             txtDistrict.Text      = license.DISTRICT_NAME;
             txtCommune.Text       = license.COMMUNE_NAME;
             txtVillage.Text       = license.VILLAGE_NAME;
             txtAddress.Text       = license.ADDRESS;
             txtEmail.Text         = license.EMAIL;
         }
         else
         {
         }
     };
 }
Beispiel #2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in dataGridViewLicense.SelectedRows)
     {
         LICENSE_NUMBER = row.Cells[1].Value.ToString();
     }
     //     MessageBox.Show(LICENSE_NUMBER);
     if (LICENSE_NUMBER == string.Empty || LICENSE_NUMBER == null)
     {
     }
     else
     {
         var result = MetroMessageBox.Show(this, "Are you sure to delete it?", "Delete", MessageBoxButtons.OKCancel);
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             using (LicenseDataContext _context = new LicenseDataContext())
             {
                 TBL_LICENSE license = (from l in _context.TBL_LICENSEs
                                        where l.ACCOUNT_NO == LICENSE_NUMBER
                                        select l).FirstOrDefault();
                 license.IS_ACTIVE = false;
                 _context.SubmitChanges();
             }
             using (TBL_LICENSE_DATA_ACCESS lda = new TBL_LICENSE_DATA_ACCESS())
             {
                 dataGridViewLicense.DataSource = lda.ShowLicense();
             }
             GC.Collect();
         }
     }
     GC.Collect();
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!invalid())
            {
                try
                {
                    using (LicenseDataContext _context = new LicenseDataContext())
                    {
                        TBL_LICENSE l = new TBL_LICENSE();

                        l.ACCOUNT_NAME  = txtPhone.Text.Trim();
                        l.ACCOUNT_NO    = txtLicenseNumber.Text.Trim();
                        l.CONTACT_NAME  = txtContactName.Text.Trim();
                        l.PHONE         = txtPhone.Text.Trim();
                        l.EMAIL         = txtEmail.Text.Trim();
                        l.PROVINCE_NAME = txtProvince.Text.Trim();
                        l.DISTRICT_NAME = txtDistrict.Text.Trim();
                        l.COMMUNE_NAME  = txtCommune.Text.Trim();
                        l.VILLAGE_NAME  = txtVillage.Text.Trim();
                        l.ADDRESS       = txtAddress.Text.Trim();
                        l.IS_ACTIVE     = true;
                        l.CREATE_ON     = Convert.ToDateTime(DateTime.Now.ToString());
                        lda.SaveLicense(l);
                    };
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
            else
            {
            }
        }
 /// <summary>
 /// Update License No.
 /// </summary>
 /// <param name="license"></param>
 public void UpdateLicense(TBL_LICENSE license)
 {
     using (_context = new LicenseDataContext())
     {
         _context.SubmitChanges();
     }
 }
 /// <summary>
 /// Delete License NO.
 /// </summary>
 /// <param name="license"></param>
 public void DeleteLicense(TBL_LICENSE license)
 {
     using (_context = new LicenseDataContext())
     {
         _context.TBL_LICENSEs.DeleteOnSubmit(license);
         _context.SubmitChanges();
     }
 }
 public void SaveLicense(TBL_LICENSE license)
 {
     using (_context = new LicenseDataContext())
     {
         _context.TBL_LICENSEs.InsertOnSubmit(license);
         _context.SubmitChanges();
     };
 }
Beispiel #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            using (LicenseDataContext _context = new LicenseDataContext())
            {
                TBL_LICENSE license = (from l in _context.TBL_LICENSEs
                                       where l.ACCOUNT_NO == txtLicenseNumber.Text
                                       select l).FirstOrDefault();

                license.ACCOUNT_NO    = txtLicenseNumber.Text.Trim();
                license.ACCOUNT_NAME  = txtAccountName.Text.Trim();
                license.PHONE         = txtPhone.Text.Trim();
                license.EMAIL         = txtEmail.Text.Trim();
                license.CONTACT_NAME  = txtContactName.Text.Trim();
                license.PHONE         = txtPhone.Text.Trim();
                license.ADDRESS       = txtAddress.Text.Trim();
                license.PROVINCE_NAME = txtProvince.Text.Trim();
                license.DISTRICT_NAME = txtDistrict.Text.Trim();
                license.COMMUNE_NAME  = txtCommune.Text.Trim();
                license.VILLAGE_NAME  = txtVillage.Text.Trim();
                _context.SubmitChanges();
            };
            this.Close();
        }