예제 #1
0
        private void okButton_Click(object sender, EventArgs e)
        {
            Client client = new Client();

            client.Name = clientNameTextBox.Text;
            client.Region = RegionComboBox.Text;
            client.Country = countryComboBox.Text;
            client.StartDate = selectedTime;
            client.BusinessType = BusinessTypeComboBox.Text;

            if (clientNameTextBox.Text == "" || RegionComboBox.Text == "" ||
                        countryComboBox.Text == "" || startDateText.Text == "" || BusinessTypeComboBox.Text == "")
            {
                MessageBox.Show("All fields required. Please check fields and try again.");
                return;
            }

            if (!ClientDataControl.NewClient(client))
            {
                MessageBox.Show("Failed to create new client: " + client.Name + " already exists", "Error");
                return;
            }

            this.Close();
        }
예제 #2
0
        //Used by ClientDataControl
        public override Client LoadClient(string clientName)
        {
            CLIENT clientEnt;

            if (!GetClient(clientName, out clientEnt))
            {
                return null;
            }

            Client client = new Client();

            client.Name = clientEnt.NAME.TrimEnd();
            client.Country = clientEnt.COUNTRY.NAME.TrimEnd();
            client.Region = clientEnt.COUNTRY.REGION.NAME.TrimEnd();
            client.BusinessType = clientEnt.BUSINESSTYPE.NAME.TrimEnd();
            client.StartDate = clientEnt.STARTDATE;
            client.EntityObject = clientEnt;
            client.BomCompleted = clientEnt.BOMCOMPLETE == "Y";
            client.CupeCompleted = clientEnt.CUPECOMPLETE == "Y";
            client.ITCapCompleted = clientEnt.ITCAPCOMPLETE == "Y";
            return client;
        }
예제 #3
0
        //Used by ClientDataControl
        public override Client AddClient(Client client)
        {
            CLIENT clientEnt = new CLIENT();

            clientEnt.NAME = client.Name.TrimEnd();

            string regionName = client.Region;
            REGION region;
            try
            {
                region = (from ent in dbo.REGION
                          where ent.NAME.TrimEnd() == regionName
                          select ent).Single();
            }
            catch
            {
                region = new REGION();
                region.NAME = client.Region;
                dbo.AddToREGION(region);
            }

            string countryName = client.Country;
            COUNTRY country;
            try
            {
                country = (from ent in region.COUNTRY
                          where ent.NAME.TrimEnd() == countryName
                          select ent).Single();
            }
            catch
            {
                country = new COUNTRY();
                country.NAME = client.Country;
                country.REGION = region;
                dbo.AddToCOUNTRY(country);
            }

            clientEnt.COUNTRY = country;

            string busTypeName = client.BusinessType;
            BUSINESSTYPE busType;
            try
            {
                busType = (from ent in dbo.BUSINESSTYPE
                          where ent.NAME.TrimEnd() == busTypeName
                          select ent).Single();
            }
            catch
            {
                busType = new BUSINESSTYPE();
                busType.NAME = client.BusinessType;
                dbo.AddToBUSINESSTYPE(busType);
            }
            clientEnt.BUSINESSTYPE = busType;

            clientEnt.STARTDATE = client.StartDate;
            clientEnt.BOMCOMPLETE = clientEnt.CUPECOMPLETE = clientEnt.ITCAPCOMPLETE = "N";

            if (!AddClient(clientEnt))
            {
                return null;
            }

            client.EntityObject = clientEnt;
            return client;
        }
예제 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Client EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToClient(Client client)
 {
     base.AddObject("Client", client);
 }
예제 #5
0
 /// <summary>
 /// Create a new Client object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 public static Client CreateClient(global::System.Int32 id)
 {
     Client client = new Client();
     client.Id = id;
     return client;
 }
예제 #6
0
 public abstract Client AddClient(Client client);
예제 #7
0
        public static bool NewClient(Client selectedClient)
        {
            client = db.AddClient(selectedClient);

            return (client != null && db.SaveChanges());
        }
예제 #8
0
        public static bool LoadClient(string clientName)
        {
            client = db.LoadClient(clientName);

            return (client != null && db.SaveChanges());
        }
예제 #9
0
        //Used by ClientDataControl
        public override Client AddClient(Client client)
        {
            XElement clientEnt = new XElement("CLIENT");

            clientEnt.Add(new XElement("NAME", client.Name));

            XElement region;
            try
            {
                region = (from ent in dbo.Element("REGIONS").Elements("REGION")
                          where ent.Element("NAME").Value == client.Region
                          select ent).Single();
            }
            catch
            {
                region = new XElement("REGION");
                region.Add(new XElement("NAME", client.Region));
                region.Add(new XElement("COUNTRIES"));
                dbo.Element("REGIONS").Add(region);
            }
            clientEnt.Add(new XElement("REGION", client.Region));

            XElement country;
            try
            {
                country = (from ent in region.Element("COUNTRIES").Elements("COUNTRY")
                           where ent.Element("NAME").Value == client.Country
                           select ent).Single();
            }
            catch
            {
                country = new XElement("COUNTRY");
                country.Add(new XElement("NAME", client.Country));
                region.Element("COUNTRIES").Add(country);
            }
            clientEnt.Add(new XElement("COUNTRY", client.Country));

            XElement busType;
            try
            {
                busType = (from ent in dbo.Element("BUSINESSTYPES").Elements("BUSINESSTYPE")
                           where ent.Element("NAME").Value == client.BusinessType
                           select ent).Single();
            }
            catch
            {
                busType = new XElement("BUSINESSTYPE");
                busType.Add(new XElement("NAME", client.BusinessType));
                dbo.Element("BUSINESSTYPES").Add(busType);
            }
            clientEnt.Add(new XElement("BUSINESSTYPE", busType));

            clientEnt.Add(new XElement("STARTDATE", client.StartDate));

            if (!AddClient(clientEnt))
            {
                return null;
            }

            clientEnt.Add(new XElement("BOMCOMPLETE", "N"));
            clientEnt.Add(new XElement("CUPECOMPLETE", "N"));
            clientEnt.Add(new XElement("ITCAPCOMPLETE", "N"));

            client.EntityObject = clientEnt;
            return client;
        }
예제 #10
0
        //Used by ClientDataControl
        public override Client LoadClient(string clientName)
        {
            XElement clientEnt;

            if (!GetClient(clientName, out clientEnt))
            {
                return null;
            }

            Client client = new Client();

            client.Name = clientEnt.Element("NAME").Value;
            client.Country = clientEnt.Element("COUNTRY").Value;
            client.Region = clientEnt.Element("REGION").Value;
            client.BusinessType = clientEnt.Element("BUSINESSTYPE").Value;
            client.StartDate = DateTime.Parse(clientEnt.Element("STARTDATE").Value);
            client.EntityObject = clientEnt;
            client.BomCompleted = clientEnt.Element("BOMCOMPLETE").Value == "Y";
            client.CupeCompleted = clientEnt.Element("CUPECOMPLETE").Value == "Y";
            client.ITCapCompleted = clientEnt.Element("ITCAPCOMPLETE").Value == "Y";
            return client;
        }