Ejemplo n.º 1
0
        public void createForDatabase()
        {
            using (ExhibitionDataForContext context = new ExhibitionDataForContext())
            {
                context.Database.Delete();
                context.Companies.Add(new Company("none"));
                context.Positions.Add(new Position("none"));
                context.Descriptions.Add(new Description("none", "none"));
                context.Cities.Add(new City("none"));
                context.Exhibits.Add(new Exhibit("none"));
                context.Raports.Add(new Raport("none"));

                context.SaveChanges();

                ExhibitionVisitor visitor = new ExhibitionVisitor();
                visitor.LastName  = "none";
                visitor.FirstName = "none";
                visitor.CompanyId = context.Companies.Where
                                        (co => co.Name.Equals("none")).Select(coc => coc.Id).FirstOrDefault();
                visitor.PositionId = context.Positions.Where
                                         (p => p.Name.Equals("none")).Select(po => po.Id).FirstOrDefault();
                visitor.PhoneNumber   = "none";
                visitor.Email         = "none";
                visitor.DescriptionId = context.Descriptions.Where
                                            (d => d.Name.Equals("none")).Select(dd => dd.Id).FirstOrDefault();
                visitor.BarCode = "none";

                visitor.CityId = context.Cities.Where
                                     (ci => ci.Name.Equals("none")).Select(cit => cit.Id).FirstOrDefault();
                visitor.ExhibitId = context.Exhibits.Where
                                        (e => e.Name.Equals("none")).Select(ex => ex.Id).FirstOrDefault();
                visitor.RaportId = context.Raports.Where(r => r.Name.Equals("none"))
                                   .Select(ra => ra.Id).FirstOrDefault();

                visitor.Status = "none";

                visitor.Payment_Status         = "none";
                visitor.Payment_Status_Comment = "none";
                visitor.Source_Code            = "none";
                visitor.Event_Code             = "none";
                visitor.Event_Name             = "none";

                context.ExhibitionVisitors.Add(visitor);
                context.SaveChanges();
            }
            status = "create database";
        }
Ejemplo n.º 2
0
        private void addVisitorToFact(ExhibitionVisitor select_visitor)
        {
            select_visitor.Status      = "fact";
            select_visitor.DateCreated = DateTime.Now;

            bs.Add(new PharmaVisitor(select_visitor, context));
            //		bs.Add(new BizVisitor(select_visitor, context));
            context.SaveChanges();
            var cl    = context.Descriptions.Where(d => d.Id == select_visitor.DescriptionId).Select(s => s.Color).FirstOrDefault();
            var col   = Color.FromName(cl);
            var count = context.ExhibitionVisitors.Where(v => v.Status != "registered").Select(s => s).Count() - 1;

            lb_count.Text      = count.ToString();
            pb_color.BackColor = col;

            string pcl = "Black";

            if (select_visitor.Payment_Status == "UNPAID")
            {
                pcl = "Red";
            }
            if (select_visitor.Payment_Status == "PAID")
            {
                pcl = "Green";
            }
            if (select_visitor.Payment_Status == "FOC")
            {
                pcl = "Blue";
            }
            var pcol = Color.FromName(pcl);

            lbl_payment_status.ForeColor = pcol;
            lbl_payment_status.Text      = select_visitor.Payment_Status;
            lbl_payment_status.Visible   = true;
            List <PharmaVisitor> dgv = null;

            initialDataGread(dgv);
            printVisitor();
        }
Ejemplo n.º 3
0
 private int getCompanyId(string s)
 {
     if (s == "")
     {
         return(context.Companies.Where(c => c.Name == "none").Select(x => x.Id).FirstOrDefault());
     }
     else
     {
         var id = context.Companies.Where(c => c.Name == s).Select(x => x.Id).FirstOrDefault();
         if (id != 0)
         {
             return(id);
         }
         else
         {
             Company company = new Company(s);
             context.Companies.Add(company);
             context.SaveChanges();
             var nid = context.Companies.Where(c => c.Name == s).Select(x => x.Id).FirstOrDefault();
             return(nid);
         }
     }
 }
Ejemplo n.º 4
0
        private void dgv_colors_DoubleClick(object sender, EventArgs e)
        {
            var         description  = bs.Current as Description;
            var         r            = dgv_colors.CurrentCell.RowIndex;
            var         color_dialog = new ColorDialog();
            var         f            = color_dialog.ShowDialog();
            var         color        = color_dialog.Color;
            Description nd           = description;

            nd.Color = color.Name;
            try
            {
                context.Descriptions.AddOrUpdate(nd);
                context.SaveChanges();
                this.dgv_colors.Refresh();
                this.dgv_colors.Rows[r].Cells[2].Style.BackColor = color;
            }
            catch { }
        }
Ejemplo n.º 5
0
        public void getForDataToDatabase()
        {
            for (int row = 0; row < excelWorksheetRow; row++)
            {
                using (ExhibitionDataForContext context = new ExhibitionDataForContext())
                {
                    var e_company = data[row, 2];
                    if (e_company.Length == 0 || e_company == " ")
                    {
                        e_company = "none";
                    }
                    if (context.Companies.Where(cc => cc.Name.Equals(e_company)).ToList().Count() == 0)
                    {
                        context.Companies.Add(new Company(e_company));
                    }

                    var e_position = data[row, 3];
                    if (e_position.Length == 0 || e_position == " ")
                    {
                        e_position = "none";
                    }
                    if (context.Positions.Where(p => p.Name.Equals(e_position)).Count() == 0)
                    {
                        context.Positions.Add(new Position(e_position));
                    }

                    var e_discription = data[row, 6];
                    if (e_discription.Length == 0 || e_discription == " ")
                    {
                        e_discription = "none";
                    }
                    if (context.Descriptions.Where(d => d.Name.Equals(e_discription)).Count() == 0)
                    {
                        context.Descriptions.Add(new Description(e_discription, "White"));
                    }

                    if (context.Cities.Where(c => c.Name.Equals("none")).Count() == 0)
                    {
                        context.Cities.Add(new City("none"));
                    }

                    if (context.Exhibits.Where(e => e.Name.Equals("none")).Count() == 0)
                    {
                        context.Exhibits.Add(new Exhibit("none"));
                    }

                    if (context.Raports.Where(r => r.Name.Equals("none")).Count() == 0)
                    {
                        context.Raports.Add(new Raport("none"));
                    }

                    context.SaveChanges();

                    ExhibitionVisitor visitor = new ExhibitionVisitor();
                    visitor.LastName  = data[row, 0];
                    visitor.FirstName = data[row, 1];

                    visitor.CityId = context.Cities.Where(ci => ci.Name.Equals
                                                              ("none")).Select(c => c.Id).FirstOrDefault();
                    visitor.ExhibitId = context.Cities.Where(e => e.Name.Equals
                                                                 ("none")).Select(ex => ex.Id).FirstOrDefault();
                    visitor.RaportId = context.Cities.Where(r => r.Name.Equals
                                                                ("none")).Select(ra => ra.Id).FirstOrDefault();

                    visitor.CompanyId = context.Companies.Where
                                            (co => co.Name.Equals(e_company)).Select(coc => coc.Id).FirstOrDefault();
                    visitor.PositionId = context.Positions.Where
                                             (p => p.Name.Equals(e_position)).Select(po => po.Id).FirstOrDefault();
                    visitor.PhoneNumber   = data[row, 4];
                    visitor.Email         = data[row, 5];
                    visitor.DescriptionId = context.Descriptions.Where
                                                (d => d.Name.Equals(e_discription)).Select(dd => dd.Id).FirstOrDefault();
                    visitor.BarCode = data[row, 7];

                    visitor.Payment_Status         = data[row, 8];
                    visitor.Payment_Status_Comment = data[row, 9];
                    visitor.Source_Code            = data[row, 10];
                    visitor.Event_Code             = data[row, 11];
                    visitor.Event_Name             = data[row, 12];

                    visitor.Status = "registered";

                    context.ExhibitionVisitors.Add(visitor);
                    context.SaveChanges();
                }
            }
            status = "get excel data to database";
        }