예제 #1
0
 private void LoadChapters(string Name = "")
 {
     using (basecampprodEntities dbs = new basecampprodEntities())
     {
         ChapterList = (from item in dbs.chapters
                         where item.Name.StartsWith(Name)
                         select item).ToList();
         DisplayChapters(ChapterList);
     }
 }
예제 #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     using (basecampprodEntities dbs = new basecampprodEntities())
     {
         var chapterdetail = (from item in dbs.chapters
                              where item.Name.ToUpper() == txtname.Text.ToUpper()
                              select item).FirstOrDefault();
         bool IsNew = chapterdetail == null ? true : false;
         chapterdetail = chapterdetail == null ? new chapter() : chapterdetail;
         chapterdetail.Name = txtname.Text.ToUpper();
         chapterdetail.Description = txtdesciption.Text.ToUpper();
         chapterdetail.Address = txtaddress.Text.ToUpper();
         chapterdetail.CreatedDate = DateTime.UtcNow;
         if (IsNew) { dbs.chapters.Add(chapterdetail); }
         dbs.SaveChanges();
         txtname.Text = "";
         txtdesciption.Text = "";
         txtaddress.Text = "";
         ChapterList.Add(chapterdetail);
     }
 }
예제 #3
0
        private dynamic EncodeLawyer(Lawyer Data)
        {
            dynamic response = new ExpandoObject();
            response.RollNumber = Data.RollNumber;
            response.Success = false;
            response.Message = "";
            try
            {
                using (TransactionScope tx = new TransactionScope())
                {
                    var dbs = new basecampprodEntities();
                    var lawyerinfo = new UserData();
                    bool IsNew = false;
                    var basicinfo = (from item in dbs.users
                                     where item.LoginID.Equals(Data.RollNumber)
                                     select item).FirstOrDefault();
                    response.Type = basicinfo == null ? Type.Insert : Type.Update;
                    response.Message = basicinfo == null ? string.Format("succesfully {0} the record", Type.Insert) : string.Format("succesfully {0} the record", Type.Update);

                    #region User Type
                    IsNew = basicinfo == null ? true : false;
                    basicinfo = basicinfo == null ? new user() : basicinfo;
                    string[] fullname = Data.Name.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    string[] name = fullname[1].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    string firstname = "";
                    for (int ii = 0; ii <= name.Length - 2; ii++)
                    {
                        firstname = firstname + " " + name[ii];
                    }
                    basicinfo.LastName = fullname[0];
                    basicinfo.FirstName = firstname;
                    basicinfo.MiddleName = name[name.Length - 1];
                    basicinfo.LoginID = Data.RollNumber;
                    basicinfo.MembershipType = Data.LifeTimeRoll == "" ? "Annual" : "LifeTime";
                    basicinfo.IBPNumber = Data.LifeTimeRoll;
                    basicinfo.AddToBar = int.Parse(Data.YearAdmitted);
                    basicinfo.IsLiving = true;
                    basicinfo.isLawyer = true;
                    if (IsNew) { dbs.users.Add(basicinfo); }
                    dbs.SaveChanges();
                    IsNew = false;
                    #endregion

                    #region UserInfo Type
                    var OtherInfo = (from item in dbs.userinfoes
                                     where item.UserID == basicinfo.UserID
                                     select item).FirstOrDefault();
                    IsNew = OtherInfo == null ? true : false;
                    OtherInfo = OtherInfo == null ? new userinfo() : OtherInfo;

                    var ChapterDetail = (from item in dbs.chapters
                                         where item.Name.ToUpper() == Data.Chapter.ToUpper()
                                         select item).FirstOrDefault();
                    if (ChapterDetail != null)
                    {
                        OtherInfo.UserID = basicinfo.UserID;
                        OtherInfo.ChapterID = ChapterDetail.ChapterID;
                        OtherInfo.Birthday = Data.BirthDate;
                        OtherInfo.Address = Data.HomePhone;
                        OtherInfo.Sex = Data.Sex.Substring(0, 1);
                        OtherInfo.CivilStatus = Data.Status;
                        OtherInfo.CreatedDate = DateTime.UtcNow;
                        if (IsNew) { dbs.userinfoes.Add(OtherInfo); }
                        dbs.SaveChanges();
                        IsNew = false;
                    }
                    else
                    {
                        throw new Exception(string.Format("{0} Chapter is not Existing in Database.", Data.Chapter));
                    }
                    #endregion

                    #region PhoneInfo Type
                    var phones = (from item in dbs.userinfophones
                                  where item.UserID == basicinfo.UserID
                                  select item).ToList();
                    foreach (var item in phones) { dbs.userinfophones.Remove(item); }
                    string[] homephones = Data.HomePhone.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    string[] offphones = Data.WorkPhone.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string phone in homephones)
                    {
                        var HomePhone = new userinfophone();
                        HomePhone.UserID = basicinfo.UserID;
                        HomePhone.Type = "Home";
                        HomePhone.SecurityType = "Private";
                        HomePhone.Number = string.Format("{0}/{1}Home", phone, basicinfo.UserID);
                        dbs.userinfophones.Add(HomePhone);
                    }
                    foreach (string phone in offphones)
                    {
                        var EmployePhone = new userinfophone();
                        EmployePhone.UserID = basicinfo.UserID;
                        EmployePhone.Type = "Office";
                        EmployePhone.SecurityType = "Private";
                        EmployePhone.Number = string.Format("{0}/{1}Office", phone, basicinfo.UserID);
                        dbs.userinfophones.Add(EmployePhone);
                    }
                    dbs.SaveChanges();
                    #endregion

                    #region EmailInfo Type
                    if (Data.Email != "")
                    {
                        var emails = (from item in dbs.userinfoemails
                                      where item.UserID == basicinfo.UserID
                                      select item).ToList();
                        foreach (var item in emails) { dbs.userinfoemails.Remove(item); }
                        var email = new userinfoemail();
                        email.UserID = basicinfo.UserID;
                        email.Type = "personal";
                        email.IsPrimary = false;
                        email.EmailAddress = Data.Email;
                        email.SecurityType = "Private";
                        dbs.userinfoemails.Add(email);
                        dbs.SaveChanges();
                    }
                    #endregion

                    #region College Type
                    var CollegeSchool = (from item in dbs.colleges
                                         where item.Name.ToUpper() == Data.LawSchool.ToUpper()
                                         select item).FirstOrDefault();
                    IsNew = CollegeSchool == null ? true : false;
                    CollegeSchool = CollegeSchool == null ? new college() : CollegeSchool;
                    CollegeSchool.Name = Data.LawSchool;
                    if (IsNew) { dbs.colleges.Add(CollegeSchool); }
                    dbs.SaveChanges();

                    var CollegeSchools = (from item in dbs.userinfocolleges
                                          where item.UserID == basicinfo.UserID
                                          select item).ToList();
                    foreach (var item in CollegeSchools) { dbs.userinfocolleges.Remove(item); }
                    var collegeInfo = new userinfocollege();
                    collegeInfo.UserID = basicinfo.UserID;
                    collegeInfo.ID = CollegeSchool.ID;
                    collegeInfo.Year = new DateTime();
                    dbs.userinfocolleges.Add(collegeInfo);
                    dbs.SaveChanges();
                    #endregion

                    #region Employer Type
                    var EmployerInfo = new employer();
                    EmployerInfo.Address = Data.WorkAddress;
                    EmployerInfo.Name = "";
                    EmployerInfo.Description = Data.Occupation;
                    dbs.employers.Add(EmployerInfo);
                    dbs.SaveChanges();

                    var empInfo = new userinfoemployer();
                    empInfo.UserID = basicinfo.UserID;
                    empInfo.ID = EmployerInfo.ID;
                    empInfo.StartYear = new DateTime();
                    empInfo.StillEmployed = true;
                    dbs.userinfoemployers.Add(empInfo);
                    dbs.SaveChanges();
                    #endregion

                    #region Specialization
                    if (Data.Specialization != "")
                    {
                        var specialization = (from item in dbs.professions
                                              where item.Name.ToUpper() == Data.Specialization.ToUpper()
                                              select item).FirstOrDefault();
                        IsNew = specialization == null ? true : false;
                        specialization = specialization == null ? new profession() : specialization;
                        specialization.Name = Data.Specialization;
                        if (IsNew)
                        {
                            dbs.professions.Add(specialization);
                        }
                        basicinfo.professions.Add(specialization);
                        dbs.SaveChanges();
                    }
                    #endregion
                    response.Success = true;
                    tx.Complete();
                    return response;
                }
            }
            catch (Exception e)
            {
                response.Type = Type.Unknown;
                string message = "";
                if (e.InnerException != null)
                {
                    if (e.InnerException.InnerException != null)
                    {
                        message = e.InnerException.InnerException.Message;
                    }
                    else
                    {
                        message = e.InnerException.Message;
                    }
                }
                else
                {
                    message = e.Message;
                }
                response.Message = message;
                return response;
            }
        }
예제 #4
0
        private void button6_Click(object sender, EventArgs e)
        {
            Excel.Workbook MyBook = null;
            Excel.Application MyApp = null;
            Excel.Worksheet MySheet = null;
            MyApp = new Excel.Application();
            MyApp.Visible = false;
            MyBook = MyApp.Workbooks.Open(@"C:\Users\Francis\Desktop\IBPExcelApp\IBPExcelApplication\bin\Debug\IBP LIFETIME MEMBERS 06182014.xlsx");
            MySheet = (Excel.Worksheet)MyBook.Sheets[1];
            var list = new List<Lawyer>();
            int init = int.Parse(txtstartTab2.Text);
            int end = int.Parse(txtendtab2.Text);
            new Thread(() =>
            {
                using (basecampprodEntities dbs = new basecampprodEntities())
                {
                    for (int i = init; i <= end; i++)
                    {
                        System.Array MyValues = (System.Array)MySheet.get_Range("A" + i.ToString(), "D" + i.ToString()).Cells.Value;
                        ListViewItem lvitem = new ListViewItem(i.ToString());
                        lvitem.SubItems.Add(MyValues.GetValue(1, 1).ToString());
                        lvitem.SubItems.Add("Update");
                        try
                        {
                            string roll = MyValues.GetValue(1, 1).ToString();
                            var UserDetail = (from item in dbs.users
                                              where item.LoginID == roll
                                              select item).FirstOrDefault();

                            UserDetail.MembershipType = "LifeTime";
                            UserDetail.IBPNumber = MyValues.GetValue(1, 4).ToString();
                            dbs.SaveChanges();
                            lvitem.SubItems.Add("Success in updating the lifetime membership");
                            lvitem.BackColor = Color.LimeGreen;
                        }
                        catch (Exception err)
                        {
                            string message = "";
                            if (err.InnerException != null)
                            {
                                if (err.InnerException.InnerException != null)
                                {
                                    message = err.InnerException.InnerException.Message;
                                }
                                else
                                {
                                    message = err.InnerException.Message;
                                }
                            }
                            else
                            {
                                message = err.Message;
                            }
                            lvitem.SubItems.Add(message);
                            lvitem.BackColor = Color.DarkRed;
                            lvitem.ForeColor = Color.White;
                        }
                        listView2.Invoke((Action)(() =>
                        {
                            listView2.Items.Add(lvitem);
                        }));
                    }
                }
            }).Start();
        }