Example #1
0
        public void CompanyList(Form _MdiForm)
        {
            CompanyList companyList = new CompanyList();

            companyList.MdiParent = _MdiForm;
            companyList.Show();
        }
        //Company Object Scope Validation check the entire object for validity...
        private byte CompanyIsValid(Company item, out string errorMessage)
        {   //validate key
            errorMessage = "";
            if (string.IsNullOrEmpty(item.CompanyID))
            {
                errorMessage = "ID Is Required.";
                return(1);
            }
            EntityStates entityState = GetCompanyState(item);

            if (entityState == EntityStates.Added && CompanyExists(item.CompanyID))
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //check cached list for duplicates...
            int count = CompanyList.Count(q => q.CompanyID == item.CompanyID);

            if (count > 1)
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //validate Description
            if (string.IsNullOrEmpty(item.Name))
            {
                errorMessage = "Name Is Required.";
                return(1);
            }
            //a value of 2 is pending changes...
            //On Commit we will give it a value of 0...
            return(2);
        }
        public async void Should_Get_All_Companies()
        {
            // given
            Company company_1 = new Company("company_name_1");
            Company company_2 = new Company("company_name_2");

            string        request     = JsonConvert.SerializeObject(company_1);
            StringContent requestBody = new StringContent(request, Encoding.UTF8, "application/json");
            await client.PostAsync("company/companies", requestBody);

            request     = JsonConvert.SerializeObject(company_2);
            requestBody = new StringContent(request, Encoding.UTF8, "application/json");
            await client.PostAsync("company/companies", requestBody);

            CompanyList companyList = new CompanyList();

            companyList.AddCompany(company_1);
            companyList.AddCompany(company_2);

            // when
            var response = await client.GetAsync("company/companies");

            // then
            response.EnsureSuccessStatusCode();
            var responseString = await response.Content.ReadAsStringAsync();

            List <Company> actualCompanies = JsonConvert.DeserializeObject <List <Company> >(responseString);
            List <Company> companies       = new List <Company>()
            {
                new Company("company_1", "company_name_1"),
                new Company("company_2", "company_name_2"),
            };

            Assert.Equal(companies, actualCompanies);
        }
        /// <summary>
        /// Retrieves list of Company objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of Company objects</returns>
        private CompanyList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //Company list
            CompanyList list = new CompanyList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    Company companyObject = new Company();
                    FillObject(companyObject, reader);

                    list.Add(companyObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
Example #5
0
        public IPagedList <Company> GetCompanies(CompanyList page, CompanySearchModel model)
        {
            var query = _session.QueryOver <Company>()
                        .Where(a => a.Parent == page);

            //if (!String.IsNullOrEmpty(model.Category))
            //{
            //    Tag tagAlias = null;
            //    query = query.JoinAlias(article => article.Tags, () => tagAlias).Where(() => tagAlias.Name.IsInsensitiveLike(model.Category, MatchMode.Exact));
            //}

            //if (model.Month.HasValue)
            //{
            //    query =
            //        query.Where(
            //            article => article.PublishOn != null && article.PublishOn.Value.MonthPart() == model.Month);
            //}
            //if (model.Year.HasValue)
            //{
            //    query =
            //        query.Where(
            //            article => article.PublishOn != null && article.PublishOn.Value.YearPart() == model.Year);
            //}

            return(query.OrderBy(x => x.Name).Asc.ThenBy(x => x.PublishOn).Desc.Paged(model.Page, page.PageSize));
        }
Example #6
0
        // will return null if unable to connect to database,
        // CompanyList.companyNames will be empty if could not find any company
        public CompanyList searchCompanies(string searchString)
        {
            Debug.consoleMsg("Got to Point 0");
            if (openConnection() == true)
            {
                Debug.consoleMsg("Got to Point 1");
                string query = "SELECT * FROM " + dbname + ".companies" + " WHERE companyName LIKE @Search;";

                MySqlCommand command = new MySqlCommand(query, connection);
                command.Parameters.AddWithValue("@Search", "%" + searchString + "%");
                MySqlDataReader reader = command.ExecuteReader();

                CompanyList   ret       = new CompanyList();
                List <string> compNames = new List <string>();

                while (reader.Read())
                {
                    string toAdd = reader.GetString("companyName");
                    if (!compNames.Contains(toAdd))
                    {
                        compNames.Add(toAdd);
                    }
                }
                ret.companyNames = compNames.ToArray <string>();

                closeConnection();
                return(ret);
            }
            else
            {
                Debug.consoleMsg("Unable to connect to database");
                return(null);
            }
        }
Example #7
0
        public CompanyList getCompanyList()
        {
            //create request
            SocketRequest socketRequest = new SocketRequest();

            socketRequest.Action = ACTION.GET_COMPANY_LIST;

            //seriliazing to JSON
            string requestAsJSON = JsonConvert.SerializeObject(socketRequest);

            //send request
            communicationController.SendMessage(requestAsJSON);

            //read resultset
            string JsonString = communicationController.ReadReplyMessage();

            CompanyList companyList = new CompanyList();

            communicationController.clientSocket.NoDelay = true;
            //deseriliasing
            companyList = JsonConvert.DeserializeObject <CompanyList>(JsonString);


            communicationController.clientSocket.Close();

            return(companyList);
        }
 private void Company_Click(object sender, RoutedEventArgs e)
 {
     ProductViewModel cancel = new ProductViewModel();
     cancel.Cancel_Product();
     CompanyList _CL = new CompanyList();
     _CL.ShowDialog();
 }
        public CompanyList GetCompanyList(String delimiter)
        {
            if (openConnection() == true)
            {
                string query = @"SELECT * FROM company WHERE companyname LIKE '%" + delimiter + "%';";

                MySqlCommand    command = new MySqlCommand(query, connection);
                MySqlDataReader reader  = command.ExecuteReader();
                List <String>   values  = new List <String>();

                while (reader.Read())
                {
                    values.Add((String)reader["companyname"]);
                }

                CompanyList value = new CompanyList();
                value.companyNames = values.ToArray();
                closeConnection();
                return(value);
            }
            else
            {
                Debug.consoleMsg("unable to connect to database");
                return(null);
            }
        }
Example #10
0
        protected void cityList_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                DistrictList.Items.Clear();
                SqlCommand command = new SqlCommand("EXEC ListAllDistrictsWithCity " + cityList.SelectedItem.Value, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                DistrictList.DataSource     = reader;
                DistrictList.DataTextField  = "Name";
                DistrictList.DataValueField = "ID";
                DistrictList.DataBind();
            }

            CompanyList.Items.Clear();
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC ShowCompanyOnDistrict " + DistrictList.SelectedItem.Value, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                CompanyList.DataSource     = reader;
                CompanyList.DataTextField  = "CompanyName";
                CompanyList.DataValueField = "ID";
                CompanyList.DataBind();
            }
        }
        public void WhenISelectMyTestCompanyFromCompanyDropdownAndSignin()
        {
            var page    = new CompanyList(Driver);
            var company = TestSetup.TestAccountCompanyName;

            page.SelectCompany(company).SignIn();
        }
Example #12
0
        /// <summary>
        /// 查询企业单位数据集合
        /// </summary>
        /// <param name="searchEntity">企业单位查询条件对象</param>
        /// <returns></returns>
        public CompanyList GetCompanyList(ParamsCompanySearch searchEntity)
        {
            Dictionary <string, string> paramsList = new Dictionary <string, string>()
            {
                { "page", searchEntity.PageIndex.ToString() },
                { "rows", searchEntity.PageSize.ToString() },
                { "unitId", searchEntity.UnitId },
                { "unitName", searchEntity.UnitName },
                { "linkman", searchEntity.linkman }
            };
            CompanyList result = CallAPIHelper.CallAPIInPOST <CompanyList>(APIAddressSetting.API_POST_GETUnitList, paramsList);

            if (result != null && result.rows != null)
            {
                result.rows.ToList().ForEach(d =>
                {
                    d.setDate = DateTimeHelper.ConvertIntToDateTimeString(d.setDate);
                    if (!string.IsNullOrEmpty(d.notused))
                    {
                        d.State = d.notused == "0" ? "已停用" : "已启用";
                    }
                });
            }
            return(result);
        }
        public CompanySearchResponse searchCompany(string companyName)
        {
            CompanyList   companyList        = new CompanyList();
            List <string> companyNamesResult = new List <string>();

            if (openConnection() == true)
            {
                string query = $@"SELECT * FROM companylistingdb.companylisting where companyname like '%{companyName}%';";

                MySqlCommand    cmd    = new MySqlCommand(query, connection);
                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    companyNamesResult.Add(reader.GetString("companyname"));
                }

                closeConnection();
                companyList.companyNames = companyNamesResult.ToArray();

                if (companyNamesResult.Count == 0)
                {
                    return(new CompanySearchResponse(false, "No companies found matching '" + companyName + "'", null));
                }
                else
                {
                    return(new CompanySearchResponse(true, "Companies found", companyList));
                }
            }
            else
            {
                throw new Exception("Unable to connect to database");
            }
        }
        public async void Should_Add_New_Employee()
        {
            // given
            Company       company             = new Company("company_name_1");
            string        request             = JsonConvert.SerializeObject(company);
            StringContent requestBody         = new StringContent(request, Encoding.UTF8, "application/json");
            CompanyList   companyList         = new CompanyList();
            Employee      employee            = new Employee("Tom", 5000);
            string        employeeRequest     = JsonConvert.SerializeObject(employee);
            StringContent employeeRequestBody = new StringContent(employeeRequest, Encoding.UTF8, "application/json");

            // when
            await client.PostAsync("company/companies", requestBody);

            string companyId = "company_1";
            var    response  = await client.PostAsync($"company/companies/{companyId}/employees", employeeRequestBody);

            // then
            response.EnsureSuccessStatusCode();
            var responseString = await response.Content.ReadAsStringAsync();

            Employee actualEmployee = JsonConvert.DeserializeObject <Employee>(responseString);

            company.AddEmployee(employee);
            Assert.Equal(employee, actualEmployee);
        }
Example #15
0
        private void Company_Button_Click(object sender, EventArgs e)
        {
            CompanyList company = new CompanyList();

            this.ShowControl(company, Content);
            //this.SetTitle("Nhập thông tin công ty");
        }
        public void DeleteCompanyCommand()
        {
            try
            {
                int i  = 0;
                int ii = 0;
                for (int j = SelectedCompanyList.Count - 1; j >= 0; j--)
                {
                    Company item = (Company)SelectedCompanyList[j];
                    //get Max Index...
                    i = CompanyList.IndexOf(item);
                    if (i > ii)
                    {
                        ii = i;
                    }
                    Delete(item);
                    CompanyList.Remove(item);
                }

                if (CompanyList != null && CompanyList.Count > 0)
                {
                    //back off one index from the max index...
                    ii = ii - 1;

                    //if they delete the first row...
                    if (ii < 0)
                    {
                        ii = 0;
                    }

                    //make sure it does not exceed the list count...
                    if (ii >= CompanyList.Count())
                    {
                        ii = CompanyList.Count - 1;
                    }

                    SelectedCompany = CompanyList[ii];
                    //we will only enable committ for dirty validated records...
                    if (Dirty == true)
                    {
                        AllowCommit = CommitIsAllowed();
                    }
                    else
                    {
                        AllowCommit = false;
                    }
                }
                else//only one record, deleting will result in no records...
                {
                    SetAsEmptySelection();
                }
            }//we try catch item delete as it may be used in another table as a key...
            //As well we will force a refresh to sqare up the UI after the botched delete...
            catch
            {
                NotifyMessage("Company/s Can Not Be Deleted.  Contact XERP Admin For More Details.");
                Refresh();
            }
        }
Example #17
0
        public void Run()
        {
            if (Status == EStatus.Working)
            {
                return;
            }

            Status = EStatus.Working;

            bool   _isLogEnabled = false;
            string setting       = System.Configuration.ConfigurationManager.AppSettings["LogEnabled"];

            bool.TryParse(setting, out _isLogEnabled);

            CompanyList empresas = null;

            try
            {
                if (_isLogEnabled)
                {
                    string msg = "AUTOPILOT::START";
                    MyLogger.LogText(msg);
                }

                AppController.Instance.InitFromService();
                Principal.Login();

                empresas = CompanyList.GetList(AppContext.User.GetInfo(), false);

                foreach (CompanyInfo item in empresas)
                {
                    MyLogger.LogText("AUTOPILOT::INFO: SCHEMA '" + item.Name + "'");

                    AppContext.Principal.ChangeUserSchema((item as ISchemaInfo));
                    AppController.Instance.AutoPilot();
                }

                if (_isLogEnabled)
                {
                    string msg = "AUTOPILOT::FINISH";
                    MyLogger.LogText(msg);
                }

                Status = EStatus.Closed;
            }
            catch (Exception ex)
            {
                Status = EStatus.Error;

                if (_isLogEnabled)
                {
                    MyLogger.LogText("AUTOPILOT::ERROR: " + iQExceptionHandler.GetAllMessages(ex, true));
                }
            }
            finally
            {
                AppController.Instance.Close();
            }
        }
Example #18
0
        public async void CreateLogin_Click()
        {
            try
            {
                if (selectCompany.USER_NAME == "" || selectCompany.USER_NAME == null)
                {
                    MessageBox.Show("Mobile No is not blank");
                }
                else if (selectCompany.PASSWORD == "" || selectCompany.PASSWORD == null)
                {
                    MessageBox.Show("Email is not blank");
                }
                else if (selectCompany.CONFIRM_PASSWORD == "" || selectCompany.CONFIRM_PASSWORD == null)
                {
                    MessageBox.Show("Customer Group is not blank");
                }

                else if (!Regex.IsMatch(selectCompany.PASSWORD,

                                        "^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$",

                                        RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)))
                {
                    MessageBox.Show("Please check Password format");
                    return;
                }

                else
                {
                    if (PASSWORD == CONFIRM_PASSWORD)
                    {
                        HttpClient client = new HttpClient();
                        client.DefaultRequestHeaders.Accept.Add(
                            new MediaTypeWithQualityHeaderValue("application/json"));
                        client.BaseAddress = new Uri(GlobalData.gblApiAdress);
                        var response = await client.PostAsJsonAsync("api/CompanyAPI/CreateLogin/", selectCompany);

                        if (response.StatusCode.ToString() == "OK")
                        {
                            MessageBox.Show("Login Details Added Successfully");
                            Cancel_Company();
                            CompanyList _CM = new CompanyList();
                            _CM.ShowDialog();
                            //Cancel_Company();
                            //Cancel_Item();

                            //ModalService.NavigateTo(new Items(), delegate(bool returnValue) { });
                        }
                    }
                    else
                    {
                        MessageBox.Show("Your Password Doesnot Matches to Confirm Password..");
                    }
                }
            }
            catch
            {
            }
        }
Example #19
0
        public void AutoBackup()
        {
            AppControllerBase.ErrorHandler = BackupErrorHandler;

            CompanyList companies = CompanyList.GetList(AppContext.User.GetInfo(), false);

            AppController.AutoBackup();
        }
 public ProducerProductsViewModel(Company company)
 {
     _company = company;
     _companyProductsService = new CompanyProductsService(_company);
     ProductsList            = _companyProductsService.GetProducts();
     CompanyList             = _companyProductsService.GetCompaniesName();
     CompanyList.Insert(0, "Companies");
 }
 public CustomerProductsViewModel(Customer customer)
 {
     _customer = customer;
     _customerProductsService = new CustomerProductsService();
     ProductsList             = _customerProductsService.GetProducts();
     CompanyList = _customerProductsService.GetCompaniesName();
     CompanyList.Insert(0, "Companies");
 }
        public ActionResult DeleteConfirmed(int id)
        {
            CompanyList companyList = db.CompanyLists.Find(id);

            db.CompanyLists.Remove(companyList);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #23
0
        protected override async Task MapEditedItemToEditor(Branch item)
        {
            SelectedCountry = CountryList.FirstOrDefault(e => e.Id == item.CountryId);
            await OnCountrySelected(SelectedCountry);

            SelectedCity    = CityList.FirstOrDefault(e => e.Id == item.CityId);
            SelectedCompany = CompanyList.FirstOrDefault(e => e.Id == item.CompanyId);
            await base.MapEditedItemToEditor(item);
        }
 public JsonResult Save(CompanyList model)
 {
     //if (!ModelState.IsValid) return Json(new { info = "Failed", status = false }, JsonRequestBehavior.AllowGet);
     if (companyListManager.SaveOrUpdate(model))
     {
         return(Json(new { info = "Saved", status = true }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { info = "Not Saved", status = false }, JsonRequestBehavior.AllowGet));
 }
Example #25
0
        public void AddCompany(Company company)
        {
            if (company == null)
            {
                throw new ArgumentNullException(nameof(company));
            }

            CompanyList.Add(company);
        }
Example #26
0
        public void RemoveCompany(Company company)
        {
            if (company == null)
            {
                throw new ArgumentNullException(nameof(company));
            }

            CompanyList.Remove(company);
        }
Example #27
0
 public NewOrderViewModel(Customer customer)
 {
     _customer = customer;
     _customerOrdersService = new CustomerOrdersService(_customer);
     ProductsList           = _customerOrdersService.GetProducts();
     CompanyList            = _customerOrdersService.GetCompaniesName();
     CompanyList.Insert(0, "Companies");
     Date = DateTimeOffset.Now;
 }
Example #28
0
        private void Company_Click(object sender, RoutedEventArgs e)
        {
            CustomerViewModel cancel = new CustomerViewModel();

            cancel.Cancel_Customer();
            CompanyList _CL = new CompanyList();

            _CL.ShowDialog();
        }
Example #29
0
        public CompanySelectForm(Form parent, CompanyList list = null)
            : base(true, parent, list)
        {
            InitializeComponent();
            _view_mode = molView.Select;

            _action_result = DialogResult.Cancel;

            Text = "Seleccione la empresa activa";
        }
 public ActionResult Edit([Bind(Include = "CompanyID,CompanyName,CorporateAddress,City,Country,PostalCode,Phone,Website,Notes,State")] CompanyList companyList)
 {
     if (ModelState.IsValid)
     {
         db.Entry(companyList).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(companyList));
 }
        private CompanyList LoadExposureDocument(IResult result) {
            CompanyList companies = new CompanyList();

            if (!Common.IsFileAvailable(ExposureFilePath)) {
                result.Errors.Add(string.Format("File not found: [{0}]", ExposureFilePath));
            }

            XmlDocument exposureXMLDoc = new XmlDocument();
            exposureXMLDoc.Load(ExposureFilePath);

            XmlNodeList companyNodeList = exposureXMLDoc.SelectNodes("/companies/company");

            foreach (XmlNode companyNode in companyNodeList) {
                Company company = new Company();
                company.CompanyId = Convert.ToInt32(companyNode.SelectSingleNode("id").InnerText);

                XmlNodeList regionNodeList = companyNode.SelectNodes("region");
                foreach (XmlNode regionNode in regionNodeList) {
                    company.Regions.Add(Convert.ToInt32(regionNode.InnerText));
                }

                companies.Add(company);
            }

            return companies;
        }