private void InitializeForm(Deputy deputy) { m_User = deputy.User; if (deputy.User == null) { m_User = new Users(); } CoverObjectUtility.SetAutoBindingData(this.tableLayoutPanel2, m_User); CoverObjectUtility.SetAutoBindingData(this.tableLayoutPanel2, deputy); cbbIsMainDeputy.Checked = deputy.IsMain; cbActive.Checked = deputy.IsActive; if (deputy.User.Sex == true) { rdNam.Checked = true; } else { rdNu.Checked = true; } if (deputy.DeputyId <= 0) { btnSaveDeputy.Visible = false; } else { btnSaveDeputy.Visible = true; } }
private void PersistDeputies(BindingList <Deputy> deputies) { foreach (var scappedDeputy in deputies) { Deputy deputy = new Deputy() { Name = scappedDeputy.Name, PoliticalParty = scappedDeputy.PoliticalParty, }; Deputymanager dm = new Deputymanager(); dm.AddDeputy(deputy); } //using (var dbContext = new SqliteDbContext()) //{ // Deputy en = new Deputy(); // { // en.Name = "aaa"; // en.PoliticalParty = "bbbb"; // // EnvoysManager.AddEnvoys(en); // } // dbContext.Deputies.Add(en); // dbContext.SaveChanges(); //} }
public async Task <Deputy> CrawlAsync(Uri url, TermOfOffice termOfOffice) { Require.NotNull(url, nameof(url)); Require.NotNull(termOfOffice, nameof(termOfOffice)); logger.LogInformation("Start Orka deputy {Url}.", url); var perfWatch = Stopwatch.StartNew(); var page = await pageRequester.MakeRequestAsync(url) .ConfigureAwait(false); var document = page.AngleSharpHtmlDocument; var list = document.QuerySelector("ul.dane1, ul.dane2"); var deputy = new Deputy { Name = GetName(list), TermOfOffice = termOfOffice, Url = url }; SetBirths(list, deputy); logger.LogInformation("Crawling Orka deputy {Url} finished. Took {Elapsed}", url, perfWatch.Elapsed); return(deputy); }
protected void button_appAuth_appoint_Click(object sender, EventArgs e) { string deptCode = ApproveAuthorityController.getDepartmentNoFromProfile(Profile.EmpNo); if (ApproveAuthorityController.getDeputyDetailsForDept(ApproveAuthorityController.getDepartmentNoFromProfile(Profile.EmpNo)).Count != 0) { ApproveAuthorityController.removeAuthority(Profile.EmpNo, deptCode, ApproveAuthorityController.getDeputyHeadOfDepartment(deptCode).EmpNo); } string empName = ddl_appAuth_deptEmps.SelectedItem.Value; int empNo = ApproveAuthorityController.getEmpNoFromEmpName(empName); DateTime dateStart = Convert.ToDateTime(txtbox_dateStart.Text).Date; DateTime dateEnd = Convert.ToDateTime(txtbox_dateEnd.Text).Date; ApproveAuthorityController.addAuthority(deptCode, empNo, dateStart, dateEnd); //checking if the employee is taking over today or later if (dateStart.CompareTo(DateTime.Today) == 0) { Deputy d = ApproveAuthorityController.getDeputyDetails(ApproveAuthorityController.getDepartmentNoFromProfile(Profile.EmpNo)); txtBox_appAuth_currentHead.Text = d.Employee.EmpName; } button_appAuth_remove.Enabled = true; BindGrid(); }
private void SetBirths(IElement list, Deputy deputy) { if (TryFindBirthElement(list, out var match)) { var birthDateText = match.Groups["Date"].Value; if (DateTime.TryParseExact(birthDateText, "dd-MM-yyyy", null, DateTimeStyles.None, out var birthDate)) { deputy.DateOfBirth = birthDate; } else { logger.LogWarning("Couldn't parse date {BirthDate}. Url: {Url}", birthDateText, deputy.Url); } if (match.Groups.Count > 1) { deputy.PlaceOfBirth = match.Groups["City"].Value; } else { logger.LogWarning("City of birth not found. Url: {Url}", deputy.Url); } } else { logger.LogWarning("Couldn't match birth. Url: {Url}", deputy.Url); } }
private void BtnUpdateSubAccout_Click(object sender, EventArgs e) { DialogResult btnSeclect = UtilityMessageBox.WarningOpeartor(NotificationMessage.MsgIsupdateQuestion); if (btnSeclect == DialogResult.No) { return; } Deputy objDeputy = _companySelect.MainDeputy; if (objDeputy == null) { UtilityMessageBox.ShowText("không có thông tin cập nhật"); return; } var objFrmDeputyEdit = new frmEditDeputy(objDeputy) { _XuLySauKhiUpdate = XuLySauKhiUpdate }; objFrmDeputyEdit.ShowDialog(); }
private void btnDeleteAccount_Click(object sender, EventArgs e) { int i = gridView1.GetSelectedRows().FirstOrDefault(); if (m_User == null || m_Deputy == null) { return; } try { using (IUnitOfWork uow = new UnitOfWork()) { uow.DeputyRepository.Remove(m_Deputy.DeputyId); uow.UsersRepository.Remove(m_User.UserId); uow.Commit(); } m_Deputy = new Deputy(); m_User = new Users(); InitializeForm(m_Deputy); gridView1.DeleteRow(i); lblNotify1.SetText(UI.removesuccess, LabelNotify.EnumStatus.Success); } catch { lblNotify1.SetText(UI.removefailed, LabelNotify.EnumStatus.Failed); } }
private void XuLySauKhiUpdate(Deputy deputy) { if (deputy == null) { return; } LoadDeputy(deputy); }
public static void AddEnvoys(Deputy en) { using (SqliteDbContext sqliteDbContext = new SqliteDbContext()) { sqliteDbContext.Deputies.Add(en); sqliteDbContext.SaveChanges(); } }
/// <summary> /// Get all Donetsk's deputies /// </summary> /// <param name="inputFileName">When null - request to server for deputies list, otherwise locale file name</param> /// <returns>List of structures 'Deputy'</returns> public static List<Deputy> GetDeputies(string inputFileName) { StreamReader streamReader; WebResponse webResponse = null; Stream stream = null; if (inputFileName == null) { var reguestGET = WebRequest.Create("https://dl.dropbox.com/u/33987496/HackatonProject/deputies.list"); reguestGET.Proxy = null; webResponse = reguestGET.GetResponse(); stream = webResponse.GetResponseStream(); if (stream == null) { throw new Exception("Can't get response from server."); } streamReader = new StreamReader(stream, Encoding.UTF8); } else { streamReader = new StreamReader(inputFileName, Encoding.UTF8); } var deputies = new List<Deputy>(); var deputy = new Deputy(); while (true) { var currentLine = streamReader.ReadLine(); if (currentLine == null) break; var tmp = currentLine.Split(','); // delete one space char deputy.Party = tmp[1].Remove(0, 1); var fullName = tmp[0].Split(' '); deputy.FirstName = fullName[1]; deputy.LastName = fullName[0]; deputy.SecondName = fullName[2]; deputies.Add(deputy); } if (webResponse != null) webResponse.Close(); if (stream != null) stream.Close(); streamReader.Close(); return deputies; }
internal Deputy Update(Deputy deputy) { _db.Execute(@" UPDATE deputies SET name = @Name WHERE id = @Id;", deputy); return(deputy); }
internal Deputy Create(Deputy deputy) { int id = _db.ExecuteScalar <int>(@" INSERT INTO deputies(name) VALUES(@Name); SELECT LAST_INSERT_ID();", deputy); deputy.Id = id; return(deputy); }
public DeputyContextMenu() { InitializeComponent(); isCopied = false; ContextItem ctxItem = new ContextItem(); ctxItem.ShowDelete = true; Init(ctxItem); m_DeputyOrigin = null; }
public static Users GetUser(Deputy deputy) { Users user; using (IUnitOfWork uow = new UnitOfWork()) { user = uow.UsersRepository.Find(deputy.UserId); uow.Commit(); } return(user); }
internal Deputy Update(Deputy deputy) { var original = _repo.GetById(deputy.Id); if (original == null) { throw new Exception("Invalid Id"); } deputy.Name = deputy.Name != null ? deputy.Name : original.Name; return(_repo.Update(deputy)); }
public ActionResult <Deputy> Create([FromBody] Deputy deputy) { try { return(Ok(_service.Create(deputy))); } catch (System.Exception error) { return(BadRequest(error.Message)); } }
public ActionResult <Deputy> Update([FromBody] Deputy deputy, int id) { try { deputy.Id = id; return(Ok(_service.Update(deputy))); } catch (System.Exception error) { return(BadRequest(error.Message)); } }
void LoadDeputy(Deputy objLoad) { if (objLoad == null) { return; } txtNameContact.Text = objLoad.DeputyName; txtPhone.Text = objLoad.Phone; txtEmail.Text = objLoad.Email; txtSexDeputy.Text = objLoad.Sex ? Constraint.SexMale: Constraint.SexFemale; txtEmail.Text = objLoad.Email; txtAcount.Text = getAccout(objLoad.UserId); }
public FrmCompany() { InitializeComponent(); FormUtility.FormatForm(this); lblNotify1.Text = ""; m_Company = null; m_Deputy = null; m_User = null; IGridviewContextMenu ctx = new CompanyContextMenu(); IGridviewContextMenu ctxDeputy = new DeputyContextMenu(); gridUtility1 = new GridUtility(gridControl1, ctxDeputy); gridUtility2 = new GridUtility(gridControl2, ctx); }
private void frmEditCustomer_Load(object sender, EventArgs e) { using (IUnitOfWork uow = new UnitOfWork()) { _objEditCompany = uow.CompanyRepository.Find(_objEditCompany.CompanyId); uow.Commit(); } cbSex.SelectedIndex = 0; txtCompanyCode.Text = _objEditCompany.CompanyCode; txtCompanyName.Text = _objEditCompany.CompanyName; txtTaxCode.Text = _objEditCompany.Taxcode; txtAddree.Text = _objEditCompany.Address; txtSwich.Text = _objEditCompany.SwiftCode; txtNoBrach.Text = (_objEditCompany.Branch != 0) ? _objEditCompany.Branch.ToString() : string.Empty; txtStaft.Text = (_objEditCompany.NumberOfEmployee != null) ? _objEditCompany.Branch.ToString() : string.Empty; txtWebsite.Text = _objEditCompany.Website; txtNote.Text = _objEditCompany.Note; txtTargertValue.Text = (_objEditCompany.TagetValue != 0) ? _objEditCompany.TagetValue.ToString() : string.Empty; cbClassCustormer.SelectedValue = _objEditCompany.ClassId; PictureUtility.BindImage(PictureSgnature, _objEditCompany.Photo); PictureUtility.BindImage(PictureLogo, _objEditCompany.PictureLogo); txtAccount.Text = _objEditCompany.Accountant; txtAccount.Text = _objEditCompany.AccountantPhone; using (IUnitOfWork uow = new UnitOfWork()) { _objMain = uow.DeputyRepository.FindMainDeputy(_objEditCompany.CompanyId); } Users user = UtilityFunction.GetUser(_objMain); string account = user != null ? user.UserName : ""; using (IUnitOfWork uow = new UnitOfWork()) { userEdit = uow.UsersRepository.IsExist(account); } if (_objMain == null) { return; } txtNameContact.Text = _objMain.DeputyName; txtEmail.Text = _objMain.Email; txtPhone.Text = _objMain.Phone; cbSex.SelectedIndex = _objMain.Sex ? 0 : 1; if (userEdit == null) { return; } txtAccount.Text = userEdit.UserName; }
/// <summary> /// Initializes a new instance of the <see cref="QuickLabor"/> class. /// </summary> /// <param name="laborersCount">The laborersCount<see cref="int"/>.</param> /// <param name="safeClose">The safeClose<see cref="bool"/>.</param> /// <param name="classObject">The classObject<see cref="object"/>.</param> /// <param name="methodName">The methodName<see cref="string"/>.</param> /// <param name="input">The input<see cref="object[]"/>.</param> public QuickLabor(int laborersCount, bool safeClose, object classObject, string methodName, params object[] input) { IDeputy am = new Deputy(classObject, methodName); LaborMethods _ant = new LaborMethods(); _ant.Put(am); Lab = new Laboratory(_ant); Lab.Scope["Primary"].LaborersCount = laborersCount; Lab.RunLaborators(); Subject = Lab.Scope["Primary"]; Visor = Subject.Visor; Laborer = Subject.Labors.AsValues().ElementAt(0).Laborer; Lab.Elaborate(am.Info.Name, input); Subject.Visor.Close(safeClose); }
public void AddDeputy(Deputy deputy) { using (SqliteDbContext context = new SqliteDbContext()) { context.Deputies.Add(deputy); try { context.SaveChanges(); } catch (Exception exception) { throw exception; } } }
private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { gridUtility1.SetRowColor(); m_Deputy = gridUtility1.GetSelectedItem <Deputy>(); if (m_Deputy == null) { return; } m_User = UtilityFunction.GetUser(m_Deputy); if (m_User == null) { return; } m_Deputy.User = m_User; InitializeForm(m_Deputy); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //get current Acting Head and print on webpage Employee deputyHead = ApproveAuthorityController.getDeputyHeadOfDepartment(ApproveAuthorityController.getDepartmentNoFromProfile(Profile.EmpNo)); Employee me = ApproveAuthorityController.getHeadOfDepartment(ApproveAuthorityController.getDepartmentNoFromProfile(Profile.EmpNo)); txtBox_appAuth_currentHead.Text = deputyHead.EmpName; //getDepartmentEmployeeList ddl_appAuth_deptEmps.DataSource = ApproveAuthorityController .getEmployeesNameInDepartment(Profile.EmpNo) .Where(x => !x.Equals(me.EmpName)); ddl_appAuth_deptEmps.DataBind(); //set date so that dates past are not allowed. txtbox_dateStart.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd"); txtbox_dateEnd.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd"); Employee head = ApproveAuthorityController.getHeadOfDepartment(ApproveAuthorityController.getDepartmentNoFromProfile(Profile.EmpNo)); if (head.EmpNo != deputyHead.EmpNo) { Deputy d = ApproveAuthorityController.getDeputyDetails(ApproveAuthorityController.getDepartmentNoFromProfile(Profile.EmpNo).ToString()); txtbox_dateStart.Text = Convert.ToDateTime(d.FromDate).ToString("yyyy-MM-dd"); txtbox_dateEnd.Text = Convert.ToDateTime(d.ToDate).ToString("yyyy-MM-dd"); } else { txtbox_dateStart.Text = DateTime.Now.ToString("yyyy-MM-dd"); txtbox_dateEnd.Text = DateTime.Now.ToString("yyyy-MM-dd"); } button_appAuth_remove.Enabled = false; lbl_currentFutureAppts.Visible = false; } //populate gridview gridView_AppAuthCurrFutAppts.DataSource = ApproveAuthorityController.getDeputyDetailsForDept(ApproveAuthorityController.getDepartmentNoFromProfile(Profile.EmpNo).ToString()); if (ApproveAuthorityController.getDeputyDetailsForDept(ApproveAuthorityController.getDepartmentNoFromProfile(Profile.EmpNo).ToString()).Count != 0) { lbl_currentFutureAppts.Visible = true; button_appAuth_remove.Enabled = true; } BindGrid(); }
public void Position_Methods() { Assert.Throws<ArgumentNullException>(() => IDeputyExtensions.Position(null)); Assert.Throws<ArgumentNullException>(() => IDeputyExtensions.Position<IDeputy>(null, "position")); Assert.Throws<ArgumentNullException>(() => Enumerable.Empty<IDeputy>().Position(null)); Assert.Throws<ArgumentException>(() => Enumerable.Empty<IDeputy>().Position(string.Empty)); Assert.Null(new Deputy().Position()); Assert.Throws<InvalidOperationException>(() => new Deputy { Position = "position" }.Position()); Assert.Equal(DeputyPosition.DumaDeputy, new Deputy { Position = "Депутат ГД" }.Position()); Assert.Equal(DeputyPosition.FederationCouncilMember, new Deputy { Position = "Член СФ" }.Position()); Assert.False(Enumerable.Empty<IDeputy>().Position("position").Any()); var first = new Deputy { Position = "First" }; var second = new Deputy { Position = "Second" }; var deputies = new[] { null, first, second }; Assert.True(ReferenceEquals(first, deputies.Position("first").Single())); }
private void InformationCustomer_Load(object sender, EventArgs e) { Deputy objmain = null; using (var uow = new UnitOfWork()) { objmain = uow.DeputyRepository.Find(_Account); if (objmain != null) { _companySelect = uow.CompanyRepository.Find((int)objmain.CompanyId); } if (_companySelect != null) { _companySelect.MainDeputy = objmain; } uow.Commit(); } InititalizeForm(_companySelect); }
private void LoadDeputy(Company company, IList <Deputy> lstDeputy = null) { if (lstDeputy == null) { using (IUnitOfWork uow = new UnitOfWork()) { lstDeputy = uow.DeputyRepository.GetByCompany(company); uow.Commit(); } } gridUtility1.BindingData <Deputy>(lstDeputy); if (lstDeputy != null) { m_Deputy = lstDeputy.Where(p => p.IsMain == true).FirstOrDefault(); if (m_Deputy == null) { m_Deputy = new Deputy(); } InitializeForm(m_Deputy); } //cbbIsMainDeputy.Checked = deputy.IsMain; }
private void button1_Click(object sender, EventArgs e) { Scraper.Scraper scrapper = new Scraper.Scraper(); scrapper.ScrapeDataOfVote("https://www.sejm.gov.pl/sejm9.nsf/agent.xsp?symbol=klubglos&IdGlosowania=54381&KodKlubu=PiS"); using (var dbContext = new SqliteDbContext()) { dbContext.Database.ExecuteSqlCommand("DELETE FROM DEPUTIES"); foreach (var dep in scrapper.Deputies) { Deputy en = new Deputy(); { en.Name = dep.Name; en.PoliticalParty = dep.PoliticalParty; } dbContext.Deputies.Add(en); } dbContext.SaveChanges(); } }
private void addBtn_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxName.Text) && string.IsNullOrEmpty(textBoxLastName.Text)) { MessageBox.Show("Podaj Imie i Nazwisko Posła"); } else { using (var dbContext = new SqliteDbContext()) { Deputy en = new Deputy(); { en.Name = textBoxName.Text; en.PoliticalParty = textBoxPoliticalPartial.Text; // EnvoysManager.AddEnvoys(en); } dbContext.Deputies.Add(en); dbContext.SaveChanges(); if (en.EnvoyID > 0) { MessageBox.Show("Id posła to " + en.EnvoyID); } else { MessageBox.Show("Błąd!"); } LoadEnvoyList(); textBoxName.Text = ""; textBoxLastName.Text = ""; textBoxPoliticalPartial.Text = ""; } } }
public frmEditDeputy(Deputy _objEdit) { InitializeComponent(); objEdit = _objEdit; }
/// <summary> /// Get all Donetsk's deputies /// </summary> /// <param name="inputFileName">When null - request to server for deputies list, otherwise locale file name</param> /// <returns>List of structures 'Deputy'</returns> public static List <Deputy> GetDeputies(string inputFileName) { StreamReader streamReader; WebResponse webResponse = null; Stream stream = null; if (inputFileName == null) { var reguestGET = WebRequest.Create("https://dl.dropbox.com/u/33987496/HackatonProject/deputies.list"); reguestGET.Proxy = null; webResponse = reguestGET.GetResponse(); stream = webResponse.GetResponseStream(); if (stream == null) { throw new Exception("Can't get response from server."); } streamReader = new StreamReader(stream, Encoding.UTF8); } else { streamReader = new StreamReader(inputFileName, Encoding.UTF8); } var deputies = new List <Deputy>(); var deputy = new Deputy(); while (true) { var currentLine = streamReader.ReadLine(); if (currentLine == null) { break; } var tmp = currentLine.Split(','); // delete one space char deputy.Party = tmp[1].Remove(0, 1); var fullName = tmp[0].Split(' '); deputy.FirstName = fullName[1]; deputy.LastName = fullName[0]; deputy.SecondName = fullName[2]; deputies.Add(deputy); } if (webResponse != null) { webResponse.Close(); } if (stream != null) { stream.Close(); } streamReader.Close(); return(deputies); }
private void btnSave_Click(object sender, EventArgs e) { if (ValidationUtility.FieldNotAllowNull(this) == false) { return; } Deputy deputy = new Deputy { Skype = txtSkype.Text, Address = txtDiaChi.Text, Email = txtEmail.Text, DeputyName = txtNameContact.Text, Phone = txtPhone.Text, CompanyId = _companyID, IsActive = true, IsMain = false, Sex = (cbSex.SelectedIndex) < 1 ? false : true, CreateBy = UserManagement.UserSession.UserName, CreateDate = DateTime.Now }; Users userNew = new Users { UserName = txtAccount.Text, Password = UtilityFunction.GetSHA256Hash(txtPassword.Text), Email = txtEmail.Text, FullName = txtNameContact.Text, CreateBy = deputy.CreateBy, CreateDate = deputy.CreateDate, UserGroupId = 2 }; Users userCheck = null; using (IUnitOfWork uow = new UnitOfWork()) { userCheck = uow.UsersRepository.IsExist(userNew.UserName); } if (userCheck != null) { UtilityMessageBox.ShowText("UserName is exit, not valid"); return; } using (IUnitOfWork uow = new UnitOfWork()) { //int k = uow.UsersRepository.Add(userNew); //deputy.UserId = k; //uow.DeputyRepository.Add(deputy); uow.Commit(); } UtilityMessageBox.ShowText("Thêm mới thành công"); if (_xulyThemMoiDeputy != null) { _xulyThemMoiDeputy(deputy); } Close(); }