Exemple #1
0
        private CEmployee GetDateFromEditors()
        {
            CEmployee     employee          = new CEmployee();
            List <string> values            = CBranch.GetEmployeeClassPropertes(employee);
            Dictionary <string, string> emp = new Dictionary <string, string>();

            for (int i = 0; i < values.Count; i++)
            {
                TextBox tb = this.Controls.Find(values[i], true).FirstOrDefault() as TextBox;
                if (tb.Text != "")
                {
                    employee[i] = tb.Text;
                }
            }

            string          pattern = @"(?'date'(?:[0-9]?\d{2}\.[0-9]?\d{2}\.[0-9]?\d{4}))";
            Regex           newReg  = new Regex(pattern);
            MatchCollection matches = newReg.Matches(employee.DateOfBirth);

            if (matches.Count == 0 && employee.DateOfBirth != "")
            {
                // throw new Exception("День рождения Должен быть в формате: дд.ММ.YYYY");
                MessageBox.Show("День рождения Должен быть в формате: дд.ММ.YYYY");
                employee = new CEmployee();
                return(employee);
            }
            employee.SetDepartmentID(EMPOLOYEE.GetDepartmentID());

            return(employee);
        }
        public CBranch Get(int id)
        {
            CBranch cBranch = new CBranch();

            cBranch = _branchService.BranchDetailGetById(id);
            return(cBranch);
        }
        private CBranch FindRoot(CBranch aBranch)
        {
            while (!aBranch.IsRoot())
            {
                aBranch = aBranch.mParent;
            }

            return(aBranch);
        }
Exemple #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            List <CDepartment> Departments = CSQL.GetDepartments();

            SetNodes(treeView1, Departments,
                     CBranch.GetDepartmentsByParentDepartmentID(Departments, "").ToList()[0] as CDepartment);
            treeView1.SelectedNode = treeView1.Nodes[0];
            UpdListEmployee(CSQL.GetEmployeesByDepartmentID(treeView1.SelectedNode.Tag.ToString()), 0);
        }
Exemple #5
0
 private void SetListEmployees(List <CEmployee> Employees)
 {
     foreach (CEmployee E in Employees)
     {
         List <string> values   = CBranch.GetEmployeeValues(E);
         ListViewItem  listitem = new ListViewItem(values.ToArray());
         listViewEmployee.Items.Add(listitem);
     }
 }
        public CWeightedUnion(int elementsCount)
        {
            mBranches = new CBranch[elementsCount];

            for (int i = 0; i < mBranches.Length; i++)
            {
                mBranches[i] = new CBranch(i);
            }
        }
Exemple #7
0
        private void SetTextInTextBoxes(CEmployee employee)
        {
            List <string> values = CBranch.GetEmployeeClassPropertes(employee);

            for (int i = 0; i < values.Count; i++)
            {
                TextBox tb = this.Controls.Find(values[i], true).FirstOrDefault() as TextBox;
                tb.Text = employee[i];//listViewEmployee.SelectedItems[0].SubItems[i].Text;
            }
        }
Exemple #8
0
        private void SetNodes(TreeView treeView, List <CDepartment> Departments, CDepartment DepartmentRoot)
        {
            List <CDepartment> SubDepartments = CBranch.GetDepartmentsByParentDepartmentID(Departments, DepartmentRoot.ID).ToList();
            TreeNode           node           = new TreeNode(DepartmentRoot.Name);

            node.Tag = DepartmentRoot.ID;
            treeView.BeginUpdate();
            treeView.Nodes.Add(node);
            FillNode(node, Departments, DepartmentRoot);
            treeView.EndUpdate();
        }
Exemple #9
0
        private void FillNode(TreeNode parentNode, List <CDepartment> Departments, CDepartment DepartmentRoot)
        {
            List <CDepartment> SubDepartments = CBranch.GetDepartmentsByParentDepartmentID(Departments, DepartmentRoot.ID).ToList();

            foreach (CDepartment D in SubDepartments)
            {
                TreeNode treeNodeSub = new TreeNode(D.Name);
                treeNodeSub.Tag = D.ID;
                parentNode.Nodes.Add(treeNodeSub);
                FillNode(treeNodeSub, Departments, D);
            }
        }
Exemple #10
0
 public BranchModel(CBranch oBranch)
 {
     BranchID  = oBranch.BranchID;
     CompanyID = oBranch.CompanyID;
     Name      = oBranch.Name;
     Address   = oBranch.Address;
     Email     = oBranch.Email;
     Location  = oBranch.Location;
     Mobile    = oBranch.Mobile;
     Username  = oBranch.Username;
     Password  = oBranch.Password;
 }
        public CTSP_BranchAndBound(ref CTSP_Distances distances, int upperBound, int numVertex)
        {
            _distances = distances;
            _upperBound = upperBound + ((upperBound * _PERCUP) / 100);
            _numVertex = numVertex;
            _bestCost = int.MaxValue;

            _optimalRoute = new List<int>();

            _tree = new CBranch(-1,-1, 0, _upperBound, new List<int>());

            _TSPupperBound = new CTSP_UpperBound(ref _distances);
        }
        public void unite(int aFirst, int aSecond)
        {
            CBranch fRoot = FindRoot(mBranches[aFirst]);
            CBranch sRoot = FindRoot(mBranches[aSecond]);

            if (fRoot.mIndex == sRoot.mIndex)
            {
                return;
            }

            sRoot.mParent = fRoot;
            fRoot.mSize  += sRoot.mSize;

            mHasUnions = true;
        }
        public CBranch BranchDetailGetById(int BranchID)
        {
            CBranch oResult = new CBranch();

            try
            {
                string spParameter = 0 + ", "
                                     + BranchID;

                // SELECT THE INFORMATION FROM THE STORE-PROCEDURE AND SET INFORMATION TO THE DATASET
                DataSet dsBranchInfo = _sqlService.GetDataSet("TBranchInfo", "uspBranchInfoGet " + spParameter);

                using (DataTable dtBranchInfo = dsBranchInfo.Tables["TBranchInfo"])
                {
                    if (dtBranchInfo.Rows.Count > 0 && BranchID > 0)
                    {
                        oResult.BranchID              = Convert.ToInt32(dtBranchInfo.Rows[0]["BranchID"].ToString());
                        oResult.CompanyID             = Convert.ToInt32(dtBranchInfo.Rows[0]["CompanyID"].ToString());
                        oResult.Name                  = dtBranchInfo.Rows[0]["Name"].ToString();
                        oResult.Address               = dtBranchInfo.Rows[0]["Address"].ToString();
                        oResult.Email                 = dtBranchInfo.Rows[0]["Email"].ToString();
                        oResult.Location              = dtBranchInfo.Rows[0]["Location"].ToString();
                        oResult.Mobile                = dtBranchInfo.Rows[0]["Mobile"].ToString();
                        oResult.Username              = dtBranchInfo.Rows[0]["Username"].ToString();
                        oResult.Password              = "******";
                        oResult.Status                = dtBranchInfo.Rows[0]["Status"].ToString();
                        oResult.LastLogged            = Convert.ToDateTime(dtBranchInfo.Rows[0]["LastLogged"].ToString());
                        oResult.LoginBeforeLastLogged = Convert.ToDateTime(dtBranchInfo.Rows[0]["LoginBeforeLastLogged"].ToString());
                        oResult.Success               = true;
                        oResult.WasSuccessful         = 1;
                    }
                    else
                    {
                        oResult.Success       = false;
                        oResult.WasSuccessful = 0;
                        oResult.Exception     = "No Record Found!";
                    }
                    return(oResult);
                }
            }
            catch (Exception ex)
            {
                oResult.Success       = false;
                oResult.WasSuccessful = 0;
                oResult.Exception     = ex.Message;
                return(oResult);
            }
        }
Exemple #14
0
        private void SetEmployeesColums(CEmployee employee)
        {
            listViewEmployee.Clear();
            listViewEmployee.View = View.Details;
            //List<string> values = CBranch.GetEmployeeClassPropertes(employee);
            List <string> values = CBranch.GetEmployeeValues(employee);

            for (int i = 0; i < values.Count; i++)
            {
                listViewEmployee.Columns.Add(values[i], 150);
            }

            listViewEmployee.FullRowSelect = true;
            listViewEmployee.GridLines     = true;
            listViewEmployee.MultiSelect   = false;
        }
        private void BranchAndBound(CBranch parentbranch, int level)
        {
            if (parentbranch._pruned)
                return;

            if (level == _numVertex) {
                //getRoute(ref parentbranch);

                parentbranch._partialRoute.Add(parentbranch._partialRoute[0]);

                parentbranch._cost += _distances.Matrix[parentbranch._partialRoute[parentbranch._partialRoute.Count - 2], parentbranch._partialRoute[parentbranch._partialRoute.Count - 1]];

                if (_bestCost > parentbranch._cost) {
                    _bestCost = parentbranch._cost;
                    _optimalRoute = parentbranch._partialRoute;
                }
            }

            int savelevel = level;

            for (int i = 0; i < _numVertex; i++) {
                if (!_TSPupperBound.isVisited(parentbranch._partialRoute, i)) {

                    List<int> partialroute = parentbranch._partialRoute.GetRange(0, parentbranch._partialRoute.Count);
                    partialroute.Add(i);

                    int cost = 0;
                    if (parentbranch._vertex != -1)
                        cost = parentbranch._cost + _distances.Matrix[parentbranch._vertex, i];

                    //int lowerbound = cost + KruskalBound(ref partialroute);
                    int lowerbound = _TSPupperBound.run(partialroute);
                    bool pruned = (lowerbound > _upperBound ? true : false);

                    parentbranch._childrenBranches.Add(new CBranch(ref parentbranch, level, i, cost, lowerbound, partialroute, pruned));
                }
            }

            foreach (CBranch branch in parentbranch._childrenBranches) {
                if (!branch._pruned) {
                    BranchAndBound(branch, level + 1);

                    level = savelevel;
                }
            }
        }
        public ActionResult View(int id)
        {
            try
            {
                // USED IN POST METHOD
                ViewBag.Header    = "View";
                ViewBag.IsSuccess = 0;
                ViewBag.Message   = "";
                fnSetProperties();

                CBranch     branch         = CFBranch.BranchDetailGetById(id);
                BranchModel objBranchModel = new BranchModel(branch);
                return(View("Edit", objBranchModel));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { Message = ex.Message, InnerException = ex.InnerException }));
            }
        }
Exemple #17
0
        private void SetTextBoxes(CEmployee employee, int x, int y)
        {
            List <string> values      = CBranch.GetEmployeeClassPropertes(employee);
            List <string> valuesInRus = CBranch.GetEmployeeValues(EMPLOEEYEEINRUS);

            int position = 0;
            int moveX, moveY;

            moveX = x;
            moveY = y;

            for (int i = 0; i < values.Count; i++)
            {
                TextBox textBoxSection = new TextBox();
                textBoxSection.Location = new System.Drawing.Point(moveX, moveY);
                textBoxSection.Name     = values[i];
                textBoxSection.Size     = new System.Drawing.Size(170, 23);
                textBoxSection.Anchor   = (AnchorStyles.Bottom | AnchorStyles.Left);
                splitContainer1.Panel2.Controls.Add(textBoxSection);

                Label Label = new Label();
                Label.Location = new System.Drawing.Point(moveX, moveY - 30);
                Label.Name     = values[i];
                //Label.Text = values[i];
                Label.Text   = valuesInRus[i];
                Label.Size   = new System.Drawing.Size(105, 23);
                Label.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
                splitContainer1.Panel2.Controls.Add(Label);

                if (position != 2)
                {
                    moveX = moveX + 200;
                    position++;
                }
                else
                {
                    position = 0;
                    moveX    = x;
                    moveY    = moveY + 60;;
                }
            }
        }
 public CBranch(ref CBranch parentBranch, int branchlevel, int vertex, int cost, int lowerBound, List<int> partialRoute, bool pruned = false)
 {
     _parentBranch = parentBranch;
     _branchlevel = branchlevel;
     _vertex = vertex;
     _cost = cost;
     _lowerBound = lowerBound;
     _pruned = pruned;
     _partialRoute = partialRoute;
     _childrenBranches = new List<CBranch>();
 }
        private void getRoute(ref CBranch lastbranch)
        {
            List<int> route = new List<int>();

            CBranch currentBranch = lastbranch;
            while (currentBranch != null) {

                route.Add(currentBranch._vertex);

                currentBranch = currentBranch._parentBranch;
            }

            route.Reverse();
            route.Add(route[0]);

            int totalCost = lastbranch._cost + _distances.Matrix[route[route.Count - 2], route[route.Count - 1]];
            //lastbranch._childrenBranches.Add(ref lastbranch, route.Count, route[route.Count - 1], totalCost, totalCost, partialroute, pruned)

            if (_bestCost > totalCost) {
                _bestCost = totalCost;
            }
        }
 public CBranch(int index)
 {
     mIndex  = index;
     mParent = this;
 }