Esempio n. 1
0
 private void tbSave_Click(object sender, EventArgs e)
 {
     using (var db = new WTCCeresEntities())
     {
         rc.CityName        = MdlDataCleasing.TrimAll(tbCityName.Text);
         rc.CityCode        = MdlDataCleasing.TrimAll(tbCityCode.Text);
         rc.CountryRegionId = Conversions.ToInteger(cboRegionCode.SelectedValue);
         if (rcService.AddOrUpdate(rc, db))
         {
             Close();
         }
     }
 }
Esempio n. 2
0
        private void BunifuButton1_Click(object sender, EventArgs e)
        {
            var cpService = new CompanyAddressService();

            cp.StreetAddress      = MdlDataCleasing.TrimAll(address1TextBox2.Text);
            cp.AddressDescription = MdlDataCleasing.TrimAll(locationDescription1TextBox1.Text);
            cp.ZipCode            = MdlDataCleasing.TrimAll(postal1TextBox1.Text);
            cp.Phone        = MdlDataCleasing.TrimAll(phone1TextBox.Text);
            cp.Fax          = MdlDataCleasing.TrimAll(fax1TextBox.Text);
            cp.RegionCityId = (int?)cboCity.SelectedValue;
            using (var db = new WTCCeresEntities())
            {
                if (cpService.AddOrUpdate(cp, db))
                {
                    My.MyProject.Forms.FrmAddOrganization.addrList.Add(cp);
                    My.MyProject.Forms.FrmAddOrganization.CompanyAddressBindingSource.DataSource = null;
                    My.MyProject.Forms.FrmAddOrganization.CompanyAddressBindingSource.DataSource = My.MyProject.Forms.FrmAddOrganization.addrList;
                    Close();
                }
            }
        }
Esempio n. 3
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            int companyId;

            lblWarning.Text = "";
            if ((isCustomer && Convert.ToInt32(cboRateTier.SelectedValue) != 0) || isCustomer == false)
            {
                using (var db = new WTCCeresEntities())
                {
                    if (Information.IsNothing(c))
                    {
                        c = new Company();
                    }
                    //
                    c.CompanyCategoryId = Conversions.ToInteger(cboCompanyCategory.SelectedValue);
                    c.CompanyCode       = MdlDataCleasing.TrimAll(tbCode.Text);
                    c.CompanyName       = MdlDataCleasing.TrimAll(tbName.Text);
                    c.Email             = MdlDataCleasing.TrimAll(tbEmail.Text);
                    c.Website           = MdlDataCleasing.TrimAll(tbWebsite.Text);
                    c.Attention         = MdlDataCleasing.TrimAll(tbAttention.Text);
                    c.Notes             = MdlDataCleasing.TrimAll(tbNotes.Text);
                    c.Rating            = rating;
                    c.IsActive          = true;
                    if (cService.AddOrUpdate(c, db))
                    {
                        companyId = cService.GetLastCompanyIdInserted();
                        if (isCustomer)
                        {
                            ccrt.CustomerRateTypeId = Conversions.ToInteger(cboRateTier.SelectedValue);
                            ccrt.CompanyId          = companyId;
                            ccrService.AddOrUpdate(ccrt, db);
                        }

                        int count = 0;
                        foreach (var addr in addrList)
                        {
                            addr.CompanyId = companyId;
                            if (count == 0)
                            {
                                addr.MainAddress = true;
                            }
                            else
                            {
                                addr.MainAddress = false;
                            }

                            caddrService.AddOrUpdate(addr, db);
                            count += 1;
                        }

                        foreach (var cct in cctList)
                        {
                            cct.CompanyId     = companyId;
                            cct.CompanyTypeId = cct.CompanyTypeId;
                            cctService.AddOrUpdate(cct, db);
                        }

                        Close();
                    }
                    else
                    {
                        My.MyProject.Forms.MessageBoxCeresOK.ShowDialog("Error", "There was an error and the information was not saved", this);
                    }
                }
            }
            else
            {
                lblWarning.Text = "Customer Rate needed.";
            }
        }