private MyKeyValuePair GetValue()
        {
            var kv = new MyKeyValuePair()
            {
                Value = "Project Not Find",
                Key   = 0
            };

            if (_row == null)
            {
                return(kv);
            }

            var jobNumber  = Convert.ToString(_row["jobNumber"]);
            var subProject = MyConvert.ConvertToInteger(_row["subProject"]);

            if (subProject > 0)
            {
                jobNumber += "-" + subProject;
            }

            kv.Value = jobNumber.ToUpper() + " - " + Convert.ToString(_row["jobTitle"]);
            kv.Key   = Convert.ToInt32(_row["jobID"]);
            return(kv);
        }
示例#2
0
        public List <MyKeyValuePair> GetValues(int[] roles)
        {
            var values = new List <MyKeyValuePair>();

            for (int i = 0; i < roles.Length; i++)
            {
                var roleID = roles[i];
                var ees    =
                    from c in _dc.FW_Employees
                    where c.Active && (c.Role == roleID || c.EmployeeNumber == 0 || c.EmployeeNumber == 110)
                    orderby c.NickName
                    select c;

                foreach (FW_Employees ee in ees)
                {
                    var kvp = new MyKeyValuePair()
                    {
                        Key   = ee.EmployeeNumber,
                        Value = ee.NickName
                    };
                    values.Add(kvp);
                }
            }
            return(values);
        }
示例#3
0
        public static List <MyKeyValuePair> GetDispatchingTaskStatus()
        {
            var k1 = new MyKeyValuePair()
            {
                Key = 201, Value = "New"
            };
            var k2 = new MyKeyValuePair()
            {
                Key = 211, Value = "Working"
            };
            var k3 = new MyKeyValuePair()
            {
                Key = 215, Value = "Outsourcing"
            };
            var k4 = new MyKeyValuePair()
            {
                Key = 221, Value = "Problem"
            };
            var k5 = new MyKeyValuePair()
            {
                Key = 231, Value = "Revise"
            };
            var k6 = new MyKeyValuePair()
            {
                Key = 2491, Value = "Finish"
            };

            return(new List <MyKeyValuePair>()
            {
                k1, k2, k3, k4, k5, k6
            });
        }
        /// <summary>
        /// 从某个配置文件中读取键为key的项的值
        /// </summary>
        /// <param name="file"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        protected string GetConfig(string file, string key)
        {
            string ret = null;

            if (File.Exists(file))
            {
                try
                {
                    XmlSerializer ser = new XmlSerializer(typeof(List <MyKeyValuePair>));
                    using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
                    {
                        List <MyKeyValuePair> items = ser.Deserialize(fs) as List <MyKeyValuePair>;
                        if (items != null && items.Count > 0)
                        {
                            MyKeyValuePair kv = items.SingleOrDefault(it => it.Key == key);
                            ret = kv != null ? kv.Value : null;
                        }
                    }
                }
                catch (Exception ex)
                {
                    LJH.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                }
            }
            return(ret);
        }
 public bool Equals(MyKeyValuePair obj)
 {
     if ((object)obj == null)
     {
         return(false);
     }
     return(this.Key.Equals(obj.Key, StringComparison.OrdinalIgnoreCase));
 }
示例#6
0
 public void AddHeadMatch(MyKeyValuePair <string, string> yourHeadMatch)
 {
     if (HeadsFilter == null)
     {
         HeadsFilter = new List <MyKeyValuePair <string, string> >();
     }
     HeadsFilter.Add(yourHeadMatch);
 }
示例#7
0
        private string GetError()
        {
            if (_errorID == 0)
            {
                return("ok");
            }
            MyKeyValuePair error = Errors.FirstOrDefault(x => x.Key == _errorID);

            return(error == null ? "Unknow Error, Contact IT please." : error.Value);
        }
示例#8
0
        private List <MyKeyValuePair> GetErrorRepository()
        {
            var e0 = new MyKeyValuePair {
                Key = 0, Value = "ok"
            };

            var e10 = new MyKeyValuePair
            {
                Key   = 10,
                Value = "Request Failed, Please select a project and try agian. "
            };
            var e12 = new MyKeyValuePair
            {
                Key   = 12,
                Value =
                    "Request Failed, you are not authorized, please contact HR to get the authorization"
            };

            var e14 = new MyKeyValuePair
            {
                Key   = 15,
                Value = "Request Failed, at least one item. "
            };


            var e50 = new MyKeyValuePair
            {
                Key   = 50,
                Value = "Request Failed, the item has been locked and can not be deleted."
            };

            var e101 = new MyKeyValuePair
            {
                Key = 101, Value = "Request Faild, Install/ship to store or location required "
            };
            var e102 = new MyKeyValuePair {
                Key = 102, Value = "Request Faild, Bill to Company Required  "
            };
            var e103 = new MyKeyValuePair {
                Key = 103, Value = "Request Faild, Quote to Company required "
            };
            var e104 = new MyKeyValuePair {
                Key = 104, Value = "Request Faild, Quote to Contact required "
            };


            return(new List <MyKeyValuePair> {
                e10, e12, e14, e50, e101, e102, e103, e104
            });
        }
    public override bool Equals(object obj)
    {
        if (obj == null)
        {
            return(false);
        }
        MyKeyValuePair p = obj as MyKeyValuePair;

        if ((object)p == null)
        {
            return(false);
        }
        return(this.Key == p.Key);
    }
        private List <MyKeyValuePair> GetStandardItemsFilteredByQueryString(QueryStringForMaterialSearch qString, IEnumerable <EST_Cost_Template> options)
        {
            var values = new List <MyKeyValuePair>();

            foreach (var opt in options)
            {
                var name = opt.Name;
                var b0   = true;
                var b1   = true;
                var b2   = true;

                if (qString.QLength >= 1)
                {
                    if (!name.ToUpper().Contains(qString.Q0))
                    {
                        b0 = false;
                    }
                }
                if (qString.QLength >= 2)
                {
                    if (!name.ToUpper().Contains(qString.Q1))
                    {
                        b1 = false;
                    }
                }
                if (qString.QLength >= 3)
                {
                    if (!name.ToUpper().Contains(qString.Q2))
                    {
                        b2 = false;
                    }
                }
                if (!(b0 & b1 & b2))
                {
                    continue;
                }

                var value = new MyKeyValuePair()
                {
                    Value = name + "--" + 0.ToString("C2") + "/" + "EA",
                    Key   = opt.TemplateID,
                };
                values.Add(value);
            }
            return(values);
        }
        private List <MyKeyValuePair> GetMaterialsFilteredByQueryString(QueryStringForMaterialSearch qString, IEnumerable <Model.Material> materials)
        {
            var values = new List <MyKeyValuePair>();

            foreach (var m in materials)
            {
                var name = MaterialCommon.GetMaterialName(m);
                var b0   = true;
                var b1   = true;
                var b2   = true;

                if (qString.QLength >= 1)
                {
                    if (!name.ToUpper().Contains(qString.Q0))
                    {
                        b0 = false;
                    }
                }
                if (qString.QLength >= 2)
                {
                    if (!name.ToUpper().Contains(qString.Q1))
                    {
                        b1 = false;
                    }
                }
                if (qString.QLength >= 3)
                {
                    if (!name.ToUpper().Contains(qString.Q2))
                    {
                        b2 = false;
                    }
                }
                if (!(b0 & b1 & b2))
                {
                    continue;
                }
                var value = new MyKeyValuePair()
                {
                    Value = name + "--" + m.Price.ToString("C2") + "/" + m.MaterialPriceUnit.UnitName,
                    Key   = m.MaterialID,
                };
                values.Add(value);
            }
            return(values);
        }
示例#12
0
        public SpecServiceAllGroup()
        {
            Values = new List <MyKeyValuePair>();
            var tbl = GetAvailableServiceGroup();

            if (tbl == null)
            {
                return;
            }

            foreach (DataRow row in tbl.Rows)
            {
                var kvp = new MyKeyValuePair();
                kvp.Key   = MyConvert.ConvertToInteger(row["Value"]);
                kvp.Value = Convert.ToString(row["Text"]);
                Values.Add(kvp);
            }
        }
示例#13
0
        public List <MyKeyValuePair> GetValues(int role)
        {
            var values = new List <MyKeyValuePair>();
            var ees    =
                from c in _dc.FW_Employees
                where c.Active && c.Role == role || c.EmployeeNumber == 0 || c.EmployeeNumber == 110
                orderby c.NickName
                select c;

            foreach (FW_Employees ee in ees)
            {
                var kvp = new MyKeyValuePair()
                {
                    Key   = ee.EmployeeNumber,
                    Value = ee.NickName
                };
                values.Add(kvp);
            }
            return(values);
        }
示例#14
0
        public List <MyKeyValuePair> GetSalesPerformanceReportEmployees()
        {
            var values = new List <MyKeyValuePair>();

            var ees =
                from c in _dc.FW_Employees
                where (c.IsShowOnPerformanceReport & c.dID == 63)
                orderby c.NickName
                select c;

            foreach (FW_Employees ee in ees)
            {
                var kvp = new MyKeyValuePair()
                {
                    Key   = ee.EmployeeNumber,
                    Value = ee.NickName
                };
                values.Add(kvp);
            }

            return(values);
        }
 /// <summary>
 /// 将某个配置保存到某个配置文件中
 /// </summary>
 /// <param name="file"></param>
 /// <param name="key"></param>
 /// <param name="value"></param>
 protected void SaveConfig(string file, string key, string value)
 {
     try
     {
         XmlSerializer         ser   = new XmlSerializer(typeof(List <MyKeyValuePair>));
         List <MyKeyValuePair> items = null;
         if (File.Exists(file))
         {
             using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
             {
                 items = ser.Deserialize(fs) as List <MyKeyValuePair>;
             }
         }
         if (items == null)
         {
             items = new List <MyKeyValuePair>();
         }
         MyKeyValuePair kv = items.SingleOrDefault(it => it.Key == key);
         if (kv != null)
         {
             kv.Value = value;
         }
         else
         {
             items.Add(new MyKeyValuePair {
                 Key = key, Value = value
             });
         }
         using (FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write))
         {
             ser.Serialize(fs, items);
         }
     }
     catch (Exception ex)
     {
         LJH.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
 }
        public CostDbItemSearchLabourHour(string q, int estCostTypeID)
        {
            var db      = new SpecificationDbEntities();
            var options = db.EST_Cost_Db_LabourHourProcedure.Where(x => x.EstCostTypeID == estCostTypeID).OrderBy(x => x.Name).ToList();

            if (!MyCommon.MyConvert.IsNullString(q))
            {
                q       = q.ToUpper();
                options = options.Where(x => x.Name.ToUpper().Contains(q)).ToList();
            }

            Values = new List <MyKeyValuePair>();
            foreach (var option in options)
            {
                var str = option.EST_Cost_Db_LabourHourPosition.RateB.ToString("C2") + "/" + "Hour";
                var acr = new MyKeyValuePair
                {
                    Value = option.Name + "--" + str,
                    Key   = option.DbItemID
                };
                Values.Add(acr);
            }
        }
示例#17
0
        private static string SolveForMatrix(int[,] inputMatrix, int noOfRows)
        {
            // let's allocate the task between Cameron and Jamie

            // Let's first alocate to J
            // sort matrix based on start time
            inputMatrix = SortMatrixOnRowsFirstValues(inputMatrix);
            string[] workAllocation = new string[noOfRows];

            MyKeyValuePair jamesAlloc   = null;
            MyKeyValuePair cameronAlloc = null;

            bool isPreConflictJames = false;

            // Now iterate through each rows
            for (int i = 0; i < noOfRows; i++)
            {
                // first check if End time of (previous allocated task) exceed this Start time of this iteration then set the allocation NULL: Assume task is already finished.
                if (jamesAlloc != null)
                {
                    // 0th Index: Start Time || 1st Index: End Time
                    if (inputMatrix[i, 0] >= jamesAlloc.End)
                    {
                        jamesAlloc = null;
                    }
                }

                // first check if End time of (previous allocated task) exceed this Start time of this iteration then set the allocation NULL: Assume task is already finished.
                if (cameronAlloc != null)
                {
                    // 0th Index: Start Time || 1st Index: End Time
                    if (inputMatrix[i, 0] >= cameronAlloc.End)
                    {
                        cameronAlloc = null;
                    }
                }

                // If no task allocated to anyone
                // give preferance to James
                if (jamesAlloc == null & cameronAlloc == null)
                {
                    if (isPreConflictJames)
                    {
                        // then create for Cameron
                        cameronAlloc = new MyKeyValuePair
                        {
                            Start = inputMatrix[i, 0],
                            End   = inputMatrix[i, 1]
                        };

                        workAllocation[i] = "C";

                        isPreConflictJames = false;
                    }
                    else
                    {
                        // James
                        jamesAlloc = new MyKeyValuePair
                        {
                            Start = inputMatrix[i, 0],
                            End   = inputMatrix[i, 1]
                        };

                        workAllocation[i]  = "J";
                        isPreConflictJames = true;
                    }
                }
                else if (jamesAlloc == null) //&& cameronAlloc == null)
                {
                    jamesAlloc = new MyKeyValuePair
                    {
                        Start = inputMatrix[i, 0],
                        End   = inputMatrix[i, 1]
                    };

                    workAllocation[i] = "J";
                }
                else if (cameronAlloc == null)
                {
                    cameronAlloc = new MyKeyValuePair
                    {
                        Start = inputMatrix[i, 0],
                        End   = inputMatrix[i, 1]
                    };

                    workAllocation[i] = "C";
                }
            }

            // Ok, let's check if re
            StringBuilder sbReturnValue = new StringBuilder();

            for (int s = 0; s < workAllocation.Length; s++)
            {
                if (string.IsNullOrWhiteSpace(workAllocation[s]))
                {
                    return("IMPOSSIBLE");
                }
                else
                {
                    sbReturnValue.Append(workAllocation[s]);
                }
            }

            return(sbReturnValue.ToString());
        }
示例#18
0
        private MyValidation GetValidateResult()
        {
            var val = new MyValidation();

            if (_material == null)
            {
                val.IsValid = false;
                var err01 = new MyKeyValuePair()
                {
                    Key   = 1,
                    Value = "Request Failed, Can't find Specified Materil",
                };
                val.ErrorMessages.Add(err01);
                return(val);
            }


            //Table JobCosting Template
            var tempalteDetails = _db.EST_Cost_Template_Detail.Where(x => x.DbItemID == (int)_material.MaterialID &
                                                                     (x.TypeID == (int)NEstCostType.ShopMaterail
                                                                      ||
                                                                      x.TypeID ==
                                                                      (int)NEstCostType.InstallationMaterail)
                                                                     ).ToList();

            if (tempalteDetails.Any())
            {
                val.IsValid = false;
                var err02 = new MyKeyValuePair()
                {
                    Key   = 2,
                    Value = "Request Failed, This material has been used in Estimation Template",
                };
                val.ErrorMessages.Add(err02);
            }


            //Table JobCostingTransaction
            var transactions = _db.JobCostingTransactions.Where(x => x.MaterialID == (int)_material.MaterialID).ToList();

            if (transactions.Any())
            {
                //NJobCostingTransactionTypeID.DirectInput

                transactions = transactions.Where(x => x.TransactionType == 0).ToList();
                if (transactions.Any())
                {
                    val.IsValid = false;
                    var err03 = new MyKeyValuePair()
                    {
                        Key   = 3,
                        Value = "Request Failed, This material has been used in Job Costing",
                    };
                    val.ErrorMessages.Add(err03);
                }
            }


            //Table JobCostingMaterialTemplateDetail
            var est = _db.JobCostingMaterialTemplateDetails.Where(x => x.MaterialID == (int)_material.MaterialID).ToList();

            if (transactions.Any())
            {
                val.IsValid = false;
                var err04 = new MyKeyValuePair()
                {
                    Key   = 4,
                    Value = "Request Failed, This material has been used in Job Costing Template",
                };
                val.ErrorMessages.Add(err04);
            }

            return(val);
        }
        private IEnumerable <MyKeyValuePair> GetErrorRepository()
        {
            var errors = new List <MyKeyValuePair>();

            var e0 = new MyKeyValuePair()
            {
                Key = 0, Value = "ok"
            };

            var e10 = new MyKeyValuePair()
            {
                Key   = 10,
                Value = "Request Failed, Please select a project and try agian. "
            };
            var e12 = new MyKeyValuePair()
            {
                Key   = 12,
                Value = "Request Failed, you are not authorized, please contact HR to get the authorization"
            };

            var e14 = new MyKeyValuePair()
            {
                Key   = 15,
                Value = "Request Failed, at least one item. "
            };


            var e50 = new MyKeyValuePair()
            {
                Key   = 50,
                Value = "Request Failed, the item has been locked and can not be deleted."
            };

            var e101 = new MyKeyValuePair()
            {
                Key = 101, Value = "Request Faild, Install/ship to store or location required "
            };
            var e102 = new MyKeyValuePair()
            {
                Key = 102, Value = "Request Faild, Bill to Company Required  "
            };
            var e103 = new MyKeyValuePair()
            {
                Key = 103, Value = "Request Faild, Quote to Company required "
            };
            var e104 = new MyKeyValuePair()
            {
                Key = 104, Value = "Request Faild, Quote to Contact required "
            };

            errors.Add(e10);
            errors.Add(e12);
            errors.Add(e14);
            errors.Add(e50);
            errors.Add(e101);
            errors.Add(e102);
            errors.Add(e103);
            errors.Add(e104);


            //Create Project
            var e1002 = new MyKeyValuePair()
            {
                Key = 1002, Value = "You had selected a sub project, sub project can not have sub project"
            };

            errors.Add(e1002);

            //Estimation
            var e1101 = new MyKeyValuePair()
            {
                Key   = 1101,
                Value = "Request Failed, The Estimation has been locked, Please Copy to a new Version. "
            };
            var e1102 = new MyKeyValuePair()
            {
                Key   = 1102,
                Value = "Request Failed, The Estimation has not been estimated, please fill out the reason you don't need it. "
            };
            var e1103 = new MyKeyValuePair()
            {
                Key   = 1103,
                Value = "Request Failed, The Estimation has been locked and can not be deleted. "
            };

            var e1104 = new MyKeyValuePair()
            {
                Key   = 1104,
                Value = "Request Failed, More details information required for Estimation, Please See the Warning ICON. "
            };


            var e1105 = new MyKeyValuePair()
            {
                Key   = 1105,
                Value = "Request Failed, Estimation exist, a Project Can only have One Estimation. "
            };

            var e1106 = new MyKeyValuePair()
            {
                Key   = 1106,
                Value = "Request Failed, This Command Only Apply to Sub-Project."
            };

            var e1107 = new MyKeyValuePair()
            {
                Key   = 1107,
                Value = "Request Failed, Estimator Is Working on this Project, Can not be Submitted."
            };

            //
            var e1108 = new MyKeyValuePair()
            {
                Key   = 1108,
                Value = "Request Failed, At Least One Active Item Required.  Active: Satatus=New / Contents Changed and Purpose=For Estimation "
            };


            errors.Add(e1101);
            errors.Add(e1102);
            errors.Add(e1103);
            errors.Add(e1104);
            errors.Add(e1105);
            errors.Add(e1106);
            errors.Add(e1107);
            errors.Add(e1108);


            return(errors);
        }
示例#20
0
        public ValidationErrorMessageProject(int errorID)
            : base(errorID)
        {
            //Create Project
            var e1002 = new MyKeyValuePair
            {
                Key = 1002, Value = "You had selected a sub project, sub project can not have sub project"
            };

            Errors.Add(e1002);

            //Estimation
            var e1101 = new MyKeyValuePair
            {
                Key   = 1101,
                Value = "Request Failed, The Estimation has been locked, Please Copy to a new Version. "
            };
            var e1102 = new MyKeyValuePair
            {
                Key   = 1102,
                Value =
                    "Request Failed, The Estimation has not been estimated, please fill out the reason you don't need it. "
            };
            var e1103 = new MyKeyValuePair
            {
                Key   = 1103,
                Value = "Request Failed, The Estimation has been locked and can not be deleted. "
            };

            var e1104 = new MyKeyValuePair
            {
                Key   = 1104,
                Value =
                    "Request Failed, More details information required for Estimation, Please See the Warning ICON. "
            };


            var e1105 = new MyKeyValuePair
            {
                Key   = 1105,
                Value = "Request Failed, Estimation exist, a Project Can only have One Estimation. "
            };

            var e1106 = new MyKeyValuePair
            {
                Key   = 1106,
                Value = "Request Failed, This Command Only Apply to Sub-Project."
            };

            var e1107 = new MyKeyValuePair
            {
                Key   = 1107,
                Value = "Request Failed, Estimator Is Working on this Project, Can not be Submitted."
            };

            //
            var e1108 = new MyKeyValuePair
            {
                Key   = 1108,
                Value =
                    "Request Failed, At Least One Active Item Required.  Active: Satatus=New / Contents Changed and Purpose=For Estimation "
            };


            Errors.Add(e1101);
            Errors.Add(e1102);
            Errors.Add(e1103);
            Errors.Add(e1104);
            Errors.Add(e1105);
            Errors.Add(e1106);
            Errors.Add(e1107);
            Errors.Add(e1108);


            //Quotation
            var e1301 = new MyKeyValuePair
            {
                Key   = 1301,
                Value = "Request Failed, Please fill out why you change quote from estimation."
            };
            var e1302 = new MyKeyValuePair
            {
                Key   = 1302,
                Value =
                    "Request Failed, Can not find Contract, Please go to the Quotation and Set it as Final"
            };

            Errors.Add(e1301);
            Errors.Add(e1302);

            //Workorder(int errorID)
            var e1501 = new MyKeyValuePair
            {
                Key   = 1501,
                Value =
                    "Request Failed, Can not copy Submitted Workorder to a new Revision, you can delete the request or ask authorized personnel to unlock the Workorder."
            };
            var e1502 = new MyKeyValuePair
            {
                Key = 1502, Value = "Request Failed, Only Approved Work order can be copied to Revise."
            };
            var e1503 = new MyKeyValuePair
            {
                Key = 1503, Value = "Request Failed, Only Approved Workorder can be copied to ReDo."
            };
            var e1504 = new MyKeyValuePair
            {
                Key   = 1504,
                Value = "Request Failed, Work order has been  locked, no more item can be added."
            };
            var e1505 = new MyKeyValuePair {
                Key = 1505, Value = "No Work Order Found."
            };
            var e1506 = new MyKeyValuePair {
                Key = 1506, Value = "Please fill out ---Reason for Add New Items--- first"
            };


            Errors.Add(e1501);
            Errors.Add(e1502);
            Errors.Add(e1503);
            Errors.Add(e1504);
            Errors.Add(e1505);
            Errors.Add(e1506);

            //Invoice(int errorID)
            var e1601 = new MyKeyValuePair
            {
                Key   = 1601,
                Value =
                    "Delete faild, this invoice is in status of Prepared or Approved, can not be deleted"
            };

            var e1602 = new MyKeyValuePair
            {
                Key   = 1602,
                Value =
                    "Request failed, Product Item amount fields should be numeric or  number with prefix $, please check and try again."
            };

            var e1603 = new MyKeyValuePair
            {
                Key   = 1603,
                Value =
                    "Request failed, Service amount fields should be numeric or  number with prefix $, please check and try again."
            };


            var e1604 = new MyKeyValuePair
            {
                Key   = 1604,
                Value =
                    "Request failed, Only Prepared Invoice Can be Approved, please check and try again."
            };

            Errors.Add(e1601);
            Errors.Add(e1602);
            Errors.Add(e1603);
            Errors.Add(e1604);
        }