public void ReplaceAll(System.Collections.Generic.IList <Person> data)
        {
            var newData = CloneAndSortBy(data, x => x.PersonId, System.Collections.Generic.Comparer <int> .Default);
            var table   = new PersonTable(newData);

            memory = new MemoryDatabase(
                memory.EnumKeyTableTable,
                memory.ItemTable,
                memory.MonsterTable,
                table,
                memory.QuestTable,
                memory.Test1Table,
                memory.Test2Table

                );
        }
Example #2
0
 public MemoryDatabase(
     QuestTable QuestTable,
     ItemTable ItemTable,
     MonsterTable MonsterTable,
     PersonTable PersonTable,
     Test1Table Test1Table,
     Test2Table Test2Table
     )
 {
     this.QuestTable   = QuestTable;
     this.ItemTable    = ItemTable;
     this.MonsterTable = MonsterTable;
     this.PersonTable  = PersonTable;
     this.Test1Table   = Test1Table;
     this.Test2Table   = Test2Table;
 }
Example #3
0
        public AgentViewModel GetAgentViewModel(int id)
        {
            AgentViewModel Agentviewmodel = (from b in db.Agent
                                             join bus in db.BusinessEntity on b.PersonID equals bus.PersonID into BusinessEntityTable
                                             from BusinessEntityTab in BusinessEntityTable.DefaultIfEmpty()
                                             join p in db.Persons on BusinessEntityTab.PersonID equals p.PersonID into PersonTable
                                             from PersonTab in PersonTable.DefaultIfEmpty()
                                             join pa in db.PersonAddress on PersonTab.PersonID equals pa.PersonId into PersonAddressTable
                                             from PersonAddressTab in PersonAddressTable.DefaultIfEmpty()
                                             join ac in db.LedgerAccount on PersonTab.PersonID equals ac.PersonId into AccountTable
                                             from AccountTab in AccountTable.DefaultIfEmpty()
                                             where PersonTab.PersonID == id
                                             select new AgentViewModel
            {
                PersonId = PersonTab.PersonID,
                Name = PersonTab.Name,
                Suffix = PersonTab.Suffix,
                Code = PersonTab.Code,
                Phone = PersonTab.Phone,
                Mobile = PersonTab.Mobile,
                Email = PersonTab.Email,
                Address = PersonAddressTab.Address,
                CityId = PersonAddressTab.CityId,
                Zipcode = PersonAddressTab.Zipcode,
                IsSisterConcern = BusinessEntityTab.IsSisterConcern,
                IsActive = PersonTab.IsActive,
                LedgerAccountGroupId = AccountTab.LedgerAccountGroupId,
                CreatedBy = PersonTab.CreatedBy,
                CreatedDate = PersonTab.CreatedDate,
                PersonAddressID = PersonAddressTab.PersonAddressID,
                AccountId = AccountTab.LedgerAccountId,
                ImageFileName = PersonTab.ImageFileName,
                ImageFolderName = PersonTab.ImageFolderName
            }).FirstOrDefault();

            var PersonRegistration = (from pp in db.PersonRegistration
                                      where pp.PersonId == id
                                      select new
            {
                PersonRegistrationId = pp.PersonRegistrationID,
                RregistrationType = pp.RegistrationType,
                RregistrationNo = pp.RegistrationNo
            }).ToList();


            return(Agentviewmodel);
        }
        public void Diff(Person[] addOrReplaceData)
        {
            var data    = DiffCore(memory.PersonTable.GetRawDataUnsafe(), addOrReplaceData, x => x.PersonId, System.Collections.Generic.Comparer <int> .Default);
            var newData = CloneAndSortBy(data, x => x.PersonId, System.Collections.Generic.Comparer <int> .Default);
            var table   = new PersonTable(newData);

            memory = new MemoryDatabase(
                memory.EnumKeyTableTable,
                memory.ItemTable,
                memory.MonsterTable,
                table,
                memory.QuestTable,
                memory.Test1Table,
                memory.Test2Table

                );
        }
        public void RemovePerson(int[] keys)
        {
            var data    = RemoveCore(memory.PersonTable.GetRawDataUnsafe(), keys, x => x.PersonId, System.Collections.Generic.Comparer <int> .Default);
            var newData = CloneAndSortBy(data, x => x.PersonId, System.Collections.Generic.Comparer <int> .Default);
            var table   = new PersonTable(newData);

            memory = new MemoryDatabase(
                memory.EnumKeyTableTable,
                memory.ItemTable,
                memory.MonsterTable,
                table,
                memory.QuestTable,
                memory.Test1Table,
                memory.Test2Table

                );
        }
Example #6
0
        private void Button_Delete_Click(object sender, EventArgs e)
        {
            Person dperson = new Person();

            foreach (Person person in records_studentsList)
            {
                if (int.Parse(textBox_ID.Text) == person.Id)
                {
                    dperson = person;
                }
            }

            manager_studentsTable.Delete(dperson);
            manager_studentsTable = new PersonTable();

            Button_view_Click(sender, e);
        }
        private async Task <Person> MapFromServerAsync(PersonTable source,
                                                       CancellationToken token = default(CancellationToken))
        {
            InternalContract.RequireNotNull(source, nameof(source));
            InternalContract.RequireValidated(source, nameof(source));
            var serverAddresses = await _storage.Address.ReadChildrenAsync(source.Id, token : token);

            var target = new Person
            {
                Id        = MapperHelper.MapToType <string, Guid>(source.Id),
                Name      = source.Name,
                Etag      = source.Etag,
                Addresses = serverAddresses.Select(CreateAndMapFromServer)
            };

            FulcrumAssert.IsValidated(target);
            return(target);
        }
Example #8
0
        /// <summary>
        /// To Update person by is
        /// </summary>
        /// <param name="id"> integer</param>
        /// <param name="value"> person object</param>
        /// <returns> 404 or 202</returns>
        // PUT: api/Person/5
        public HttpResponseMessage Put(long id, [FromBody] Person value)
        {
            PersonTable p = new PersonTable();
            bool        recoredExisted = false;

            recoredExisted = p.UpdatePerson(id, value);
            HttpResponseMessage Response; // creating a response object

            if (recoredExisted)
            {
                Response = Request.CreateResponse(HttpStatusCode.NoContent);
            }
            else
            {
                Response = Request.CreateResponse(HttpStatusCode.NotFound);
            }
            return(Response);
        }
        public IQueryable <PersonContactViewModel> GetPersonContactListForIndex(int PersonId)
        {
            var temp = from pc in db.PersonContacts
                       join p in db.Persons on pc.ContactId equals p.PersonID into PersonTable
                       from PersonTab in PersonTable.DefaultIfEmpty()
                       orderby pc.PersonContactID
                       where pc.PersonId == PersonId
                       select new PersonContactViewModel
            {
                PersonContactId = pc.PersonContactID,
                Name            = PersonTab.Name,
                Phone           = PersonTab.Phone,
                Mobile          = PersonTab.Mobile,
                Email           = PersonTab.Email
            };

            return(temp);
        }
Example #10
0
        public IQueryable <EmployeeIndexViewModel> GetEmployeeListForIndex()
        {
            var temp = from p in db.Employee
                       join p1 in db.Persons on p.PersonID equals p1.PersonID into PersonTable
                       from PersonTab in PersonTable.DefaultIfEmpty()
                       orderby PersonTab.Name
                       select new EmployeeIndexViewModel
            {
                PersonId = PersonTab.PersonID,
                Name     = PersonTab.Name,
                Code     = PersonTab.Code,
                Mobile   = PersonTab.Mobile,
                Phone    = PersonTab.Phone,
                Suffix   = PersonTab.Suffix,
            };

            return(temp);
        }
Example #11
0
        /// <summary>
        /// Deletes a Person and it requirs an ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        // DELETE: api/Person/5
        public HttpResponseMessage Delete(long id)
        {
            PersonTable P = new PersonTable();

            bool recoredExisted = false;

            recoredExisted = P.DeletePerson(id);

            HttpResponseMessage Response; // creating a response object

            if (recoredExisted)
            {
                Response = Request.CreateResponse(HttpStatusCode.NoContent);
            }
            else
            {
                Response = Request.CreateResponse(HttpStatusCode.NotFound);
            }
            return(Response);
        }
Example #12
0
        public ComboBoxPagedResult GetListWithProcess(string searchTerm, int pageSize, int pageNum, int ProcessId)
        {
            int CurrentSiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
            int CurrentDivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];

            string DivId  = "|" + CurrentDivisionId.ToString() + "|";
            string SiteId = "|" + CurrentSiteId.ToString() + "|";

            var list = (from b in _JobworkerRepository.Instance
                        join bus in _unitOfWork.Repository <BusinessEntity>().Instance on b.PersonID equals bus.PersonID into BusinessEntityTable
                        from BusinessEntityTab in BusinessEntityTable.DefaultIfEmpty()
                        join p in _unitOfWork.Repository <Person>().Instance on b.PersonID equals p.PersonID into PersonTable
                        from PersonTab in PersonTable.DefaultIfEmpty()
                        join pp in _unitOfWork.Repository <PersonProcess>().Instance on b.PersonID equals pp.PersonId into PersonProcessTable
                        from PersonProcessTab in PersonProcessTable.DefaultIfEmpty()
                        where PersonProcessTab.ProcessId == ProcessId &&
                        (string.IsNullOrEmpty(searchTerm) ? 1 == 1 : (PersonTab.Name.ToLower().Contains(searchTerm.ToLower()) || PersonTab.Code.ToLower().Contains(searchTerm.ToLower()))) &&
                        BusinessEntityTab.DivisionIds.IndexOf(DivId) != -1 &&
                        (PersonTab.IsActive == null ? 1 == 1 : PersonTab.IsActive == true) &&
                        BusinessEntityTab.SiteIds.IndexOf(SiteId) != -1
                        orderby PersonTab.Name
                        select new ComboBoxResult
            {
                id = b.PersonID.ToString(),
                text = PersonTab.Name + "|" + PersonTab.Code,
            }
                        );

            var temp = list
                       .Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList();

            var count = list.Count();

            ComboBoxPagedResult Data = new ComboBoxPagedResult();

            Data.Results = temp;
            Data.Total   = count;

            return(Data);
        }
        public ManufacturerViewModel GetManufacturerViewModel(int id)
        {
            ManufacturerViewModel Manufacturerviewmodel = (from b in db.Manufacturer
                                                           join p in db.Persons on b.PersonID equals p.PersonID into PersonTable
                                                           from PersonTab in PersonTable.DefaultIfEmpty()
                                                           where PersonTab.PersonID == id
                                                           select new ManufacturerViewModel
            {
                PersonId = PersonTab.PersonID,
                Name = PersonTab.Name,
                Suffix = PersonTab.Suffix,
                Code = PersonTab.Code,
                Description = PersonTab.Description,
                IsActive = PersonTab.IsActive,
                CreatedBy = PersonTab.CreatedBy,
                CreatedDate = PersonTab.CreatedDate,
                ImageFileName = PersonTab.ImageFileName,
                ImageFolderName = PersonTab.ImageFolderName
            }).FirstOrDefault();

            return(Manufacturerviewmodel);
        }
Example #14
0
        public IQueryable <BuyerIndexViewModel> GetBuyerListForIndex()
        {
            var temp = from b in db.Buyer
                       join p in db.Persons on b.PersonID equals p.PersonID into PersonTable
                       from PersonTab in PersonTable.DefaultIfEmpty()
                       join add in db.PersonAddress on PersonTab.PersonID equals add.PersonId
                       into table2
                       from addres in table2.DefaultIfEmpty()
                       orderby PersonTab.Name
                       select new BuyerIndexViewModel
            {
                PersonId = PersonTab.PersonID,
                Name     = PersonTab.Name,
                Code     = PersonTab.Code,
                Suffix   = PersonTab.Suffix,
                Mobile   = PersonTab.Mobile,
                Address  = addres.Address,
                City     = addres.City.CityName,
            };

            return(temp);
        }
Example #15
0
        static void Main(string[] args)
        {
            Database db = new Database();

            db.Connect();


            Address a1 = new Address("Žilina", "Fatranská 6");
            Address a2 = new Address("Martin", "Martinská 6");
            //AddressTable.Insert(a1, db);
            //AddressTable.Insert(a2, db);

            Person p1 = new Person(generateString(8), generateString(8), null, "+421" + generateString(9),
                                   generateString(4) + "@email.com", "Muz", a1, a1.Id);

            PersonTable.Insert(p1);

            //Person p1 = new Person("Lukáš","Paučin","1996-06-19", "+)

            /*
             * Person p1 = new Person();
             * p1.Id = 1;
             * p1.FirstName = "Lukáš";
             * p1.LastName = "Paučin";
             * p1.BirthDay = null;
             * p1.PhoneNumber = "+421521645";
             * p1.Email = "*****@*****.**";
             * p1.Gender = "Muz";
             * p1.Address = a1;
             * p1.AddressId = a1.Id;
             *
             * PersonTable.Insert(p1, db);
             */

            db.Close();
        }
Example #16
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                //Identify IDNumber from Users table
                AspNetUser currentUser = db.AspNetUsers.Where(v => v.Email.Equals(model.Email)).First();
                string     IDNo        = currentUser.IDNumber;

                //Add user to Persons table
                int building = db.PersonTables.Where(v => v.IDNumber.Equals(IDNo)).Count();
                if (building < 1)
                {
                    var newPerson = new PersonTable {
                        Deleted = false, IDNumber = IDNo, PhoneNumber = currentUser.PhoneNumber
                    };
                    var newWallet = new PersonWallet {
                        CurrentAmount = 10000, Email = null, LastUpdate = DateTime.Now, PersonTable = newPerson
                    };
                    db.PersonTables.Add(newPerson);
                    db.PersonWallets.Add(newWallet);
                    db.SaveChanges();
                }
                else
                {
                    PersonTable pt       = db.PersonTables.Where(v => v.IDNumber.Equals(currentUser.IDNumber)).First();
                    long        idPerson = pt.PersonID;
                    int         walenje  = db.PersonWallets.Where(v => v.PersonID == idPerson).ToList().Count();
                    if (walenje < 1)
                    {
                        var newWallet = new PersonWallet {
                            CurrentAmount = 10000, Email = null, LastUpdate = DateTime.Now, PersonTable = pt
                        };
                        db.PersonWallets.Add(newWallet);
                        db.SaveChanges();
                    }
                }

                return(RedirectToLocal(returnUrl));

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
Example #17
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, PhoneNumber = model.Phonenumber, IDNumber = model.IDNumber
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    //Add user to Persons table
                    int building = db.PersonTables.Where(v => v.IDNumber.Equals(model.IDNumber)).Count();
                    if (building < 1)
                    {
                        var newPerson = new PersonTable {
                            Deleted = false, IDNumber = model.IDNumber, PhoneNumber = model.Phonenumber
                        };
                        var newWallet = new PersonWallet {
                            CurrentAmount = 10000, Email = null, LastUpdate = DateTime.Now, PersonTable = newPerson
                        };
                        db.PersonTables.Add(newPerson);
                        db.PersonWallets.Add(newWallet);
                        db.SaveChanges();
                    }
                    else
                    {
                        PersonTable pt = db.PersonTables.Where(v => v.IDNumber.Equals(model.IDNumber)).First();
                        pt.PhoneNumber = model.Phonenumber;
                        long idPerson = pt.PersonID;
                        int  walenje  = db.PersonWallets.Where(v => v.PersonID == idPerson).Count();
                        if (walenje < 1)
                        {
                            var newWallet = new PersonWallet {
                                CurrentAmount = 10000, Email = null, LastUpdate = DateTime.Now, PersonTable = pt
                            };
                            db.PersonWallets.Add(newWallet);
                            db.SaveChanges();
                        }
                        else
                        {
                            //Just save your own changes
                            db.SaveChanges();
                        }
                    }


                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
 public OracleTest()
 {
     table = new PersonTable();
 }
Example #19
0
        public Form2(string b, string p_id = "")
        {
            InitializeComponent();

            if (b == "add")
            {
                //add
                Player_add_edit.Visible  = true;
                label2.Visible           = false;
                button2.Visible          = true;
                button1.Visible          = false;
                textBox3.Visible         = false;
                button3.Visible          = false;
                TransferButton.Visible   = false;
                comboBoxTransfer.Visible = false;

                foreach (var r in role)
                {
                    comboBoxRole.Items.Add(r);
                }
                comboBoxRole.SelectedIndex = -1;


                var games = GameTable.Select();
                foreach (Game g in games)
                {
                    comboBoxGame.Items.Add(g.Name);
                }
                comboBoxGame.SelectedIndex = -1;


                var teams = TeamTable.Select();
                foreach (Team t in teams)
                {
                    comboBoxTeam.Items.Add(t.Name);
                    comboBoxTransfer.Items.Add(t.Name);
                }
                comboBoxTeam.SelectedIndex     = -1;
                comboBoxTransfer.SelectedIndex = -1;
            }
            if (b == "detail")
            {
                //detail
                Player_add_edit.Visible = false;
                label2.Visible          = true;
                button1.Visible         = true;
                button2.Visible         = false;

                Person p = new Person();
                p = PersonTable.SelectOne(Int32.Parse(p_id));

                textBox1.Text = p.First_Name;
                textBox5.Text = p.Last_Name;
                textBox4.Text = p.Birth_Date.ToString();

                textBox3.Text    = p_id.ToString();
                textBox3.Visible = false;
                setReadonly(true);
                label2.Text              = "Player detail";
                button2.Visible          = false;
                button1.Visible          = false;
                TransferButton.Visible   = false;
                comboBoxTransfer.Visible = false;

                button3.Visible = true;

                int idx = 0;

                foreach (var r in role)
                {
                    comboBoxRole.Items.Add(r);
                    if (p.Role == r)
                    {
                        comboBoxRole.SelectedIndex = idx;
                    }
                    idx++;
                }

                var games = GameTable.Select();
                foreach (Game g in games)
                {
                    comboBoxGame.Items.Add(g.Name);
                }
                comboBoxGame.SelectedIndex = p.Game_Id.Id - 1;


                var teams = TeamTable.Select();
                foreach (Team t in teams)
                {
                    comboBoxTeam.Items.Add(t.Name);
                    comboBoxTransfer.Items.Add(t.Name);
                }
                comboBoxTeam.SelectedIndex = p.Team_Id.Id - 1;
            }
            if (b == "edit")
            {
                Player_add_edit.Visible = false;
                label2.Visible          = true;
                button1.Visible         = true;
                button2.Visible         = false;

                Person p = new Person();
                p = PersonTable.SelectOne(Int32.Parse(p_id));

                textBox1.Text = p.First_Name;
                textBox5.Text = p.Last_Name;
                textBox4.Text = p.Birth_Date.ToString();

                textBox3.Text    = p_id.ToString();
                textBox3.Visible = false;
                button3.Visible  = true;

                setReadonly(false);
                label2.Text              = "Edit player";
                button2.Visible          = false;
                button1.Visible          = true;
                TransferButton.Visible   = true;
                comboBoxTransfer.Visible = true;

                int idx = 0;
                foreach (var r in role)
                {
                    comboBoxRole.Items.Add(r);
                    if (p.Role == r)
                    {
                        comboBoxRole.SelectedIndex = idx;
                    }
                    idx++;
                }

                var games = GameTable.Select();
                foreach (Game g in games)
                {
                    comboBoxGame.Items.Add(g.Name);
                }
                comboBoxGame.SelectedIndex = p.Game_Id.Id - 1;


                var teams = TeamTable.Select();
                foreach (Team t in teams)
                {
                    comboBoxTeam.Items.Add(t.Name);
                    comboBoxTransfer.Items.Add(t.Name);
                }
                comboBoxTeam.SelectedIndex = p.Team_Id.Id - 1;
            }
        }
Example #20
0
        public SupplierViewModel GetSupplierViewModel(int id)
        {
            SupplierViewModel Supplierviewmodel = (from b in db.Supplier
                                                   join bus in db.BusinessEntity on b.PersonID equals bus.PersonID into BusinessEntityTable
                                                   from BusinessEntityTab in BusinessEntityTable.DefaultIfEmpty()
                                                   join p in db.Persons on BusinessEntityTab.PersonID equals p.PersonID into PersonTable
                                                   from PersonTab in PersonTable.DefaultIfEmpty()
                                                   join pa in db.PersonAddress on PersonTab.PersonID equals pa.PersonId into PersonAddressTable
                                                   from PersonAddressTab in PersonAddressTable.DefaultIfEmpty()
                                                   join ac in db.LedgerAccount on PersonTab.PersonID equals ac.PersonId into AccountTable
                                                   from AccountTab in AccountTable.DefaultIfEmpty()
                                                   where PersonTab.PersonID == id
                                                   select new SupplierViewModel
            {
                PersonId = PersonTab.PersonID,
                Name = PersonTab.Name,
                Suffix = PersonTab.Suffix,
                Code = PersonTab.Code,
                Phone = PersonTab.Phone,
                Mobile = PersonTab.Mobile,
                Email = PersonTab.Email,
                Address = PersonAddressTab.Address,
                CityId = PersonAddressTab.CityId,
                Zipcode = PersonAddressTab.Zipcode,
                IsSisterConcern = BusinessEntityTab.IsSisterConcern,
                PersonRateGroupId = BusinessEntityTab.PersonRateGroupId,
                CreaditDays = BusinessEntityTab.CreaditDays,
                CreaditLimit = BusinessEntityTab.CreaditLimit,
                IsActive = PersonTab.IsActive,
                SalesTaxGroupPartyId = b.SalesTaxGroupPartyId,
                LedgerAccountGroupId = AccountTab.LedgerAccountGroupId,
                CreatedBy = PersonTab.CreatedBy,
                CreatedDate = PersonTab.CreatedDate,
                PersonAddressID = PersonAddressTab.PersonAddressID,
                AccountId = AccountTab.LedgerAccountId,
                SiteIds = BusinessEntityTab.SiteIds,
                DivisionIds = BusinessEntityTab.DivisionIds,
                Tags = PersonTab.Tags,
                ImageFileName = PersonTab.ImageFileName,
                ImageFolderName = PersonTab.ImageFolderName
            }).FirstOrDefault();

            var PersonProcess = (from pp in db.PersonProcess
                                 where pp.PersonId == id
                                 select new
            {
                ProcessId = pp.ProcessId
            }).ToList();

            foreach (var item in PersonProcess)
            {
                if (Supplierviewmodel.ProcessIds == "" || Supplierviewmodel.ProcessIds == null)
                {
                    Supplierviewmodel.ProcessIds = item.ProcessId.ToString();
                }
                else
                {
                    Supplierviewmodel.ProcessIds = Supplierviewmodel.ProcessIds + "," + item.ProcessId.ToString();
                }
            }


            var PersonRegistration = (from pp in db.PersonRegistration
                                      where pp.PersonId == id
                                      select new
            {
                PersonRegistrationId = pp.PersonRegistrationID,
                RregistrationType = pp.RegistrationType,
                RregistrationNo = pp.RegistrationNo
            }).ToList();

            if (PersonRegistration != null)
            {
                foreach (var item in PersonRegistration)
                {
                    if (item.RregistrationType == PersonRegistrationType.CstNo)
                    {
                        Supplierviewmodel.PersonRegistrationCstNoID = item.PersonRegistrationId;
                        Supplierviewmodel.CstNo = item.RregistrationNo;
                    }

                    if (item.RregistrationType == PersonRegistrationType.TinNo)
                    {
                        Supplierviewmodel.PersonRegistrationTinNoID = item.PersonRegistrationId;
                        Supplierviewmodel.TinNo = item.RregistrationNo;
                    }
                }
            }

            string Divisions = Supplierviewmodel.DivisionIds;

            if (Divisions != null)
            {
                Divisions = Divisions.Replace('|', ' ');
                Supplierviewmodel.DivisionIds = Divisions;
            }

            string Sites = Supplierviewmodel.SiteIds;

            if (Sites != null)
            {
                Sites = Sites.Replace('|', ' ');
                Supplierviewmodel.SiteIds = Sites;
            }

            return(Supplierviewmodel);
        }
 public MySqlORMTest()
 {
     table = new PersonTable();
 }
Example #22
0
        /// <summary>
        /// Get All Person
        /// </summary>
        /// <returns></returns>
        public ArrayList Get()
        {
            PersonTable personTable = new PersonTable();

            return(personTable.GetPersons());
        }
        public PersonViewModel GetPersonViewModel(int id)
        {
            PersonViewModel PersonViewModel = (from bus in db.BusinessEntity
                                               join p in db.Persons on bus.PersonID equals p.PersonID into PersonTable
                                               from PersonTab in PersonTable.DefaultIfEmpty()
                                               join pa in db.PersonAddress on PersonTab.PersonID equals pa.PersonId into PersonAddressTable
                                               from PersonAddressTab in PersonAddressTable.DefaultIfEmpty()
                                               join ac in db.LedgerAccount on PersonTab.PersonID equals ac.PersonId into AccountTable
                                               from AccountTab in AccountTable.DefaultIfEmpty()
                                               where PersonTab.PersonID == id
                                               select new PersonViewModel
            {
                PersonID = PersonTab.PersonID,
                Name = PersonTab.Name,
                Suffix = PersonTab.Suffix,
                Code = PersonTab.Code,
                Phone = PersonTab.Phone,
                Mobile = PersonTab.Mobile,
                Email = PersonTab.Email,
                Address = PersonAddressTab.Address,
                CityId = PersonAddressTab.CityId,
                CityName = PersonAddressTab.City.CityName,
                Zipcode = PersonAddressTab.Zipcode,
                PersonRateGroupId = bus.PersonRateGroupId,
                CreaditDays = bus.CreaditDays,
                CreaditLimit = bus.CreaditLimit,
                IsActive = PersonTab.IsActive,
                SalesTaxGroupPartyId = bus.SalesTaxGroupPartyId,
                CreatedBy = PersonTab.CreatedBy,
                CreatedDate = PersonTab.CreatedDate,
                SiteIds = bus.SiteIds,
                Tags = PersonTab.Tags,
                ImageFileName = PersonTab.ImageFileName,
                ImageFolderName = PersonTab.ImageFolderName,
                IsSisterConcern = (bool?)bus.IsSisterConcern ?? false,
                AccountId = (int?)AccountTab.LedgerAccountId ?? 0,
                PersonAddressID = (PersonAddressTab == null ? 0 : PersonAddressTab.PersonAddressID),
                LedgerAccountGroupId = (int?)AccountTab.LedgerAccountGroupId ?? 0,
            }).FirstOrDefault();

            var PersonRegistration = (from pp in db.PersonRegistration
                                      where pp.PersonId == id
                                      select new
            {
                PersonRegistrationId = pp.PersonRegistrationID,
                RregistrationType = pp.RegistrationType,
                RregistrationNo = pp.RegistrationNo
            }).ToList();

            if (PersonRegistration != null)
            {
                foreach (var item in PersonRegistration)
                {
                    if (item.RregistrationType == PersonRegistrationType.CstNo)
                    {
                        PersonViewModel.PersonRegistrationCstNoID = item.PersonRegistrationId;
                        PersonViewModel.CstNo = item.RregistrationNo;
                    }

                    if (item.RregistrationType == PersonRegistrationType.TinNo)
                    {
                        PersonViewModel.PersonRegistrationTinNoID = item.PersonRegistrationId;
                        PersonViewModel.TinNo = item.RregistrationNo;
                    }

                    if (item.RregistrationType == PersonRegistrationType.PANNo)
                    {
                        PersonViewModel.PersonRegistrationPanNoID = item.PersonRegistrationId;
                        PersonViewModel.PanNo = item.RregistrationNo;
                    }

                    if (item.RregistrationType == PersonRegistrationType.GstNo)
                    {
                        PersonViewModel.PersonRegistrationGstNoID = item.PersonRegistrationId;
                        PersonViewModel.GstNo = item.RregistrationNo;
                    }

                    if (item.RregistrationType == PersonRegistrationType.AadharNo)
                    {
                        PersonViewModel.PersonRegistrationAadharNoID = item.PersonRegistrationId;
                        PersonViewModel.AadharNo = item.RregistrationNo;
                    }
                }
            }

            return(PersonViewModel);
        }
        public IQueryable <DispatchWaybillHeaderViewModel> GetDispatchWaybillHeaderList(int DocTypeId, string Uname)
        {
            IQueryable <DispatchWaybillHeaderViewModel> DispatchWaybillHeader = from H in db.DispatchWaybillHeader
                                                                                join p in db.Persons on H.ConsigneeId equals p.PersonID into PersonTable
                                                                                from PersonTab in PersonTable.DefaultIfEmpty()
                                                                                join s in db.SaleInvoiceHeader on H.SaleInvoiceHeaderId equals s.SaleInvoiceHeaderId into SaleInvoiceHeaderTable
                                                                                from SaleInvoiceHeaderTab in SaleInvoiceHeaderTable.DefaultIfEmpty()
                                                                                where H.DocTypeId == DocTypeId
                                                                                orderby H.DispatchWaybillHeaderId
                                                                                select new DispatchWaybillHeaderViewModel
            {
                DispatchWaybillHeaderId = H.DispatchWaybillHeaderId,
                DocDate                = H.DocDate,
                DocNo                  = H.DocNo,
                ConsigneeName          = PersonTab.Name,
                SaleInvoiceHeaderDocNo = SaleInvoiceHeaderTab.DocNo,
                WaybillNo              = H.WaybillNo,
                WaybillDate            = H.WaybillDate,
                Remark                 = H.Remark,
                Status                 = H.Status,
                ModifiedBy             = H.ModifiedBy,
                ReviewCount            = H.ReviewCount,
                ReviewBy               = H.ReviewBy,
                Reviewed               = (SqlFunctions.CharIndex(Uname, H.ReviewBy) > 0),
            };

            return(DispatchWaybillHeader);
        }
Example #25
0
        public CourierViewModel GetCourierViewModel(int id)
        {
            CourierViewModel Courierviewmodel = (from b in db.Courier
                                                 join bus in db.BusinessEntity on b.PersonID equals bus.PersonID into BusinessEntityTable
                                                 from BusinessEntityTab in BusinessEntityTable.DefaultIfEmpty()
                                                 join p in db.Persons on BusinessEntityTab.PersonID equals p.PersonID into PersonTable
                                                 from PersonTab in PersonTable.DefaultIfEmpty()
                                                 join pa in db.PersonAddress on b.PersonID equals pa.PersonId into PersonAddressTable
                                                 from PersonAddressTab in PersonAddressTable.DefaultIfEmpty()
                                                 join ac in db.LedgerAccount on b.PersonID equals ac.PersonId into AccountTable
                                                 from AccountTab in AccountTable.DefaultIfEmpty()
                                                 where b.PersonID == id
                                                 select new CourierViewModel
            {
                PersonId = b.PersonID,
                Name = PersonTab.Name,
                Suffix = PersonTab.Suffix,
                Code = PersonTab.Code,
                Phone = PersonTab.Phone,
                Mobile = PersonTab.Mobile,
                Email = PersonTab.Email,
                Address = PersonAddressTab.Address,
                CityId = PersonAddressTab.CityId,
                Zipcode = PersonAddressTab.Zipcode,
                TdsCategoryId = BusinessEntityTab.TdsCategoryId,
                TdsGroupId = BusinessEntityTab.TdsGroupId,
                IsActive = PersonTab.IsActive,
                LedgerAccountGroupId = AccountTab.LedgerAccountGroupId,
                CreatedBy = PersonTab.CreatedBy,
                CreatedDate = PersonTab.CreatedDate,
                PersonAddressID = PersonAddressTab.PersonAddressID,
                AccountId = AccountTab.LedgerAccountId,
                ImageFileName = PersonTab.ImageFileName,
                ImageFolderName = PersonTab.ImageFolderName
            }
                                                 ).FirstOrDefault();

            var PersonRegistration = (from pp in db.PersonRegistration
                                      where pp.PersonId == id
                                      select new
            {
                PersonRegistrationId = pp.PersonRegistrationID,
                RregistrationType = pp.RegistrationType,
                RregistrationNo = pp.RegistrationNo
            }).ToList();

            if (PersonRegistration != null)
            {
                foreach (var item in PersonRegistration)
                {
                    if (item.RregistrationType == PersonRegistrationType.PANNo)
                    {
                        Courierviewmodel.PersonRegistrationPanNoID = item.PersonRegistrationId;
                        Courierviewmodel.PanNo = item.RregistrationNo;
                    }

                    if (item.RregistrationType == PersonRegistrationType.ServiceTaxNo)
                    {
                        Courierviewmodel.PersonRegistrationServiceTaxNoID = item.PersonRegistrationId;
                        Courierviewmodel.ServiceTaxNo = item.RregistrationNo;
                    }

                    if (item.RregistrationType == PersonRegistrationType.KYCNo)
                    {
                        Courierviewmodel.PersonRegistrationKYCNoID = item.PersonRegistrationId;
                        Courierviewmodel.KYCNo = item.RregistrationNo;
                    }
                }
            }

            return(Courierviewmodel);
        }
 public SqlServerTest()
 {
     table = new PersonTable();
 }
 public BusinessEntity GetBusinessEntityByName(string BusinessEntity)
 {
     return((from b in db.BusinessEntity
             join p in db.Persons on b.PersonID equals p.PersonID into PersonTable from PersonTab in PersonTable.DefaultIfEmpty()
             where PersonTab.Name == BusinessEntity
             select b
             ).FirstOrDefault());
 }
Example #28
0
        public BuyerViewModel GetBuyerViewModel(int id)
        {
            BuyerViewModel buyerviewmodel = (from b in db.Buyer
                                             join bus in db.BusinessEntity on b.PersonID equals bus.PersonID into BusinessEntityTable
                                             from BusinessEntityTab in BusinessEntityTable.DefaultIfEmpty()
                                             join p in db.Persons on b.PersonID equals p.PersonID into PersonTable
                                             from PersonTab in PersonTable.DefaultIfEmpty()
                                             join pa in db.PersonAddress on PersonTab.PersonID equals pa.PersonId into PersonAddressTable
                                             from PersonAddressTab in PersonAddressTable.DefaultIfEmpty()
                                             join ac in db.LedgerAccount on PersonTab.PersonID equals ac.PersonId into AccountTable
                                             from AccountTab in AccountTable.DefaultIfEmpty()
                                             where PersonTab.PersonID == id
                                             select new BuyerViewModel
            {
                PersonId = PersonTab.PersonID,
                Name = PersonTab.Name,
                Suffix = PersonTab.Suffix,
                Code = PersonTab.Code,
                Phone = PersonTab.Phone,
                Mobile = PersonTab.Mobile,
                Email = PersonTab.Email,
                Address = PersonAddressTab.Address,
                CityId = PersonAddressTab.CityId,
                Zipcode = PersonAddressTab.Zipcode,
                PersonRateGroupId = BusinessEntityTab.PersonRateGroupId,
                CreaditDays = BusinessEntityTab.CreaditDays,
                CreaditLimit = BusinessEntityTab.CreaditLimit,
                IsActive = PersonTab.IsActive,
                SalesTaxGroupPartyId = BusinessEntityTab.SalesTaxGroupPartyId,
                CreatedBy = PersonTab.CreatedBy,
                CreatedDate = PersonTab.CreatedDate,
                SiteIds = BusinessEntityTab.SiteIds,
                Tags = PersonTab.Tags,
                ImageFileName = PersonTab.ImageFileName,
                ImageFolderName = PersonTab.ImageFolderName,
                ParentId = BusinessEntityTab.ParentId,
                GuarantorId = BusinessEntityTab.GuarantorId,
                IsSisterConcern = (bool?)BusinessEntityTab.IsSisterConcern ?? false,
                AccountId = (int?)AccountTab.LedgerAccountId ?? 0,
                PersonAddressID = (PersonAddressTab == null ? 0 : PersonAddressTab.PersonAddressID),
                LedgerAccountGroupId = (int?)AccountTab.LedgerAccountGroupId ?? 0,
            }).FirstOrDefault();

            var PersonRegistration = (from pp in db.PersonRegistration
                                      where pp.PersonId == id
                                      select new
            {
                PersonRegistrationId = pp.PersonRegistrationID,
                RregistrationType = pp.RegistrationType,
                RregistrationNo = pp.RegistrationNo
            }).ToList();

            if (PersonRegistration != null)
            {
                foreach (var item in PersonRegistration)
                {
                    if (item.RregistrationType == PersonRegistrationType.CstNo)
                    {
                        buyerviewmodel.PersonRegistrationCstNoID = item.PersonRegistrationId;
                        buyerviewmodel.CstNo = item.RregistrationNo;
                    }

                    if (item.RregistrationType == PersonRegistrationType.TinNo)
                    {
                        buyerviewmodel.PersonRegistrationTinNoID = item.PersonRegistrationId;
                        buyerviewmodel.TinNo = item.RregistrationNo;
                    }
                }
            }

            string Sites = buyerviewmodel.SiteIds;

            if (Sites != null)
            {
                Sites = Sites.Replace('|', ' ');
                buyerviewmodel.SiteIds = Sites;
            }

            return(buyerviewmodel);
        }
Example #29
0
        static void Main(string[] args)
        {
            Database db = new Database();

            db.Connect();


            /***1.1 Vloženie užívateľa***/
            Address a1 = new Address("Bratislava", "Lomnická 9");

            AddressTable.Insert(a1);
            a1.Id = AddressTable.SelectMaxId(db);

            Person p1 = new Person("Lukáš", "Náhodný", "1996-10-12", "+421" + RandomString("number", 9),
                                   RandomString("word", 5) + "@email.com", "muz", a1, a1.Id);

            PersonTable.Insert(p1);
            p1.Id = PersonTable.SelectMaxId(db);


            User u1 = new User((p1.LastName.Substring(0, 3) + RandomString("number", 4)).ToLower(),
                               "courier", p1, p1.Id);

            UserTable.Insert(u1);
            u1.Id = UserTable.SelectMaxId(db);



            /***1.2 Aktualizácia užívateľa***/
            p1.LastName = "Aktualizovaný";
            PersonTable.Update(p1);
            u1.Login = (p1.LastName.Substring(0, 3) + RandomString("number", 4)).ToLower();
            UserTable.Update(u1);


            /***1.3 Zrušenie užívateľa**/
            //int UserToDelete = 15;
            //UserTable.Delete(UserToDelete);
            //PersonTable.Delete(UserToDelete);
            //Console.WriteLine("User with ID " + UserToDelete + " has been deleted." );
            //Console.WriteLine(" ");

            List <Shipment> Shipments2 = ShipmentTable.SelectAllShipments(db);

            foreach (var shipment in Shipments2)
            {
                Console.WriteLine(shipment.Id);
            }

            /*List<Shipment> ShipmentsD = ShipmentTable.SelectShipmentDetail(21,db);
             *
             * foreach (var shipment in ShipmentsD)
             * {
             *  Console.WriteLine(shipment.Id.ToString() +  shipment.Type + " " + shipment.Price + " " + shipment.DeliveryPrice + " " +
             *      shipment.Weight + " " + shipment.OrderTime + " " + shipment.DeliveryTime);
             * }*/


            /**1.4 Zoznam užívateľov**/
            List <User> Users = UserTable.SelectUsers(db);

            Console.WriteLine("(1.4)User list");

            foreach (var user in Users)
            {
                Console.WriteLine("  " + user.Id + "  " + user.Person.FullName + " " + user.Login + "   " +
                                  user.Type + " " + user.Person.Email + " " + user.Person.Address.City + "...");
            }
            Console.WriteLine(" ");


            /***1.5 Detail užívateľa***/
            User UserDetail = UserTable.SelectUser(p1.Id, db);

            Console.WriteLine("(1.5)User detail with ID: " + p1.Id + " " + UserDetail.Person.FullName + " " +
                              UserDetail.Login + " " + UserDetail.Type + " " + UserDetail.Person.Address.City + "....");
            Console.WriteLine(" ");


            /***2.1 Zoznam neskoro doručených zásielok (podľa id kuriéra)***/
            int             CourierToCheckId = 3;
            List <Shipment> LateShipments    = ShipmentTable.SelectLateShipmentsByCourierId(CourierToCheckId, db);

            Console.WriteLine("(2.1)Late shipments by courier id");

            foreach (var shipment in LateShipments)
            {
                Console.WriteLine(" " + shipment.Id.ToString() + " with " + shipment.Delay.ToString() + " day(s) delay. " + "Delivered " +
                                  shipment.Delivered + " instead of " + shipment.DeliveryTime);
            }
            Console.WriteLine(" ");


            /***2.2 Ukončené zásielky***/
            string StateToCheck = "zrusena zakaznikom"; /*vyzdvihnuta, nevyzdvihnuta*/

            ;           List <Shipment> DoneShipments = ShipmentTable.SelectDoneShipmentsByState(StateToCheck, db);
            Console.WriteLine("(2.2)Done shipments by state");

            foreach (var shipment in DoneShipments)
            {
                Console.WriteLine(" " + shipment.Id + " done at " + shipment.DoneAt);
            }
            Console.WriteLine(" ");


            /***2.3 Nedoručené zásielky***/
            int             IdOfCourierChecking = 5;
            List <Shipment> NotDoneShipments    = ShipmentTable.SelectNotDoneShipmentsByCourierId(IdOfCourierChecking, db);

            Console.WriteLine("(2.3)My shipments to deliver");

            foreach (var shipment in NotDoneShipments)
            {
                Console.WriteLine(" " + shipment.Id + " should be delivered at " + shipment.DeliveryTime +
                                  " to " + shipment.Person.FullName);
            }
            Console.WriteLine(" ");


            /***2.4 Počet jednotlivých zásielok pre ich stavy (u každého kuriéra)***/
            List <User> ShipmentsByState = ShipmentTable.SelectShipmentsByState(db);

            Console.WriteLine("(2.4)Shipment count by its state with courierID");
            Console.WriteLine(" " + "Courier ID" + "   Picked   Not Picked   Canceled   On way");

            foreach (var user in ShipmentsByState)
            {
                Console.WriteLine("      " + user.Id + "         " + user.CourPicked + "         " + user.CourNotPicked
                                  + "            " + user.CourCanceled + "         " + user.CourOnWay);
            }
            Console.WriteLine(" ");


            /***2.5 Aktuálne meškajúce zásielky (kuriéra)***/
            List <Shipment> CurrLateShipments = ShipmentTable.SelectCurrLateShipmentsByCourierId(7, db);

            Console.WriteLine("(2.5)My currently late shipments");

            foreach (var shipment in CurrLateShipments)
            {
                Console.WriteLine(" " + shipment.Id + " should be delivered " + shipment.Delay + " day(s) ago.");
            }
            Console.WriteLine(" ");

            /***3.3 Vloženie novej zásielky a automatická aktualizácia cien a váhy***/
            Console.WriteLine("(3.3)Adding new shipment...");
            Person p2 = new Person("Neregistrovaný", "Užívateľ", "1996-10-12", "+421" + RandomString("number", 9),
                                   RandomString("word", 5) + "@email.com", "muz", a1, a1.Id);

            PersonTable.Insert(p2);
            p2.Id = PersonTable.SelectMaxId(db);

            string productIds            = "4,5,6"; /* ID produtkov, ktoré si užívateľ vyberie v rozhraní*/;
            String CreateAndUpdateResult = ShipmentTable.CreateAndUpdateShipment("Test funkcie 3.3.", p2.Id, 1, 4, 2, productIds, db);

            Console.WriteLine(CreateAndUpdateResult);
            Console.WriteLine(" ");

            /***3.4 Automatická aktualizácia ceny doručenia pri oneskorenom doručení a upozornenie zákazníka o tejto udalosti***/
            Console.WriteLine("(3.4)Updating shipment delivery prices and sending notifications...");
            Console.WriteLine(ShipmentTable.LateShipNotificationAndUpdate("Ospravedlňujeme sa za meškanie vašej zásielky.", db));
            Console.WriteLine(" ");

            /***3.5 História a pohyb zásielky***/
            String Updated = ShipmentTable.HistoryAndMovement(11122, "zrusena zakaznikom", 4, db);

            Console.WriteLine("(3.5) " + Updated);

            Console.ReadLine();


            db.Close();
        }
Example #30
0
        public ActionResult Edit([Bind(Include = "BuildingID,LandRefNo,BuildingType,BuildingName,BuildingOwner,PaymentStatus,Arrears")] Building building, string payout)
        {
            oathAccount accYetu = new oathAccount(consumeKey, consumeSec);

            if (ModelState.IsValid)
            {
                db.Entry(building).State = EntityState.Modified;
                db.Entry(building).Property(uco => uco.BuildingAddress).IsModified = false;
                db.Entry(building).Property(uco => uco.BuildingFloors).IsModified  = false;

                string val = payout;
                string annualAmount;

                //Get building owner number
                PersonTable payer = db.PersonTables.Where(v => v.PersonID.Equals(building.BuildingOwner)).First();

                //send MPesa Request
                MPesaExpressRequest requestSend = new MPesaExpressRequest();

                //Record DateTime
                DateTime wakati = DateTime.Now;

                string pwd = createPassword(bsc, pKey, wakati);

                var tf = requestSend.send(int.Parse(bsc), pwd, wakati, int.Parse(payout), payer.PhoneNumber, parB, "Express", "Building Payment", accYetu.Token, building);

                if (tf.Contains("errorCode"))
                {
                    ErrorInfo           ef  = JsonConvert.DeserializeObject <ErrorInfo>(tf);
                    PaymentTrailMessage ptm = new PaymentTrailMessage
                    {
                        ResponseCode        = ef.errorCode,
                        ResponseDescription = ef.errorMessage,
                        CheckoutRequestID   = ef.requestId,
                        IDNumber            = building.LandRefNo.ToString(),
                        PaymentStamp        = DateTime.Now
                    };
                    db.PaymentTrailMessages.Add(ptm);

                    return(RedirectToAction("Edit"));
                }
                else
                {
                    TokenInfo x = JsonConvert.DeserializeObject <TokenInfo>(tf);
                    //Insert Payment Trail Messages
                    PaymentTrailMessage ptm = new PaymentTrailMessage
                    {
                        ResponseCode        = x.ResponseCode.ToString(),
                        ResponseDescription = x.ResponseDescription,
                        CheckoutRequestID   = x.CheckoutRequestID,
                        MerchantRequestID   = x.MerchantRequestID,
                        CustomerMessage     = x.CustomerMessage,
                        IDNumber            = building.LandRefNo.ToString(),
                        PaymentStamp        = DateTime.Now
                    };

                    db.PaymentTrailMessages.Add(ptm);

                    //Update DB
                    db.SaveChanges();


                    TempData["CheckOutID"] = x.CheckoutRequestID;

                    return(RedirectToAction("PaymentConfirmation", "Intermediate"));
                }
            }

            return(RedirectToAction("Edit"));
        }