Esempio n. 1
0
    public static void Main()
    {
        ClassEmp[] employee = new ClassEmp[4];
        employee[0] = new ClassEmp();
        employee[1] = new PartTime();
        employee[2] = new FullTime();
        employee[3] = new TempTime();

        //created an array of base class and to each element we assigned a different type of base class object

        // now create an array to loop through each base class object

        // since we have a base class reference variable referenceing to child classses, though we have the method in child overriding parent class
        //the base class method is called

        // the new keyword is used to hide the base class but our intension is to override the definition provided by base class, use override
        // for this mark the parent method virtual
        // this indicated the child class that it can override the parent class if it wishes to do so

        //though the ref variable is of type parent, the runtime checks the type of object, then it invokes the overriden method in the child class
        // this is called polymorphism

        // Polymorphism enables us to invoke the derived class methods using base class reference variables at run time

        // if the child class do not have any implementation overriding the parent class, then the parent class method is executed

        foreach (ClassEmp E in employee)
        {
            E.printfullname();
        }
    }
        public static DateTime GetCorrectTime(string[] values, out bool IsDateRequired)
        {
            DateTime TempBellDate;
            TimeSpan TempTime;
            string   datetime, date, time = string.Empty;

            IsDateRequired = true;
            date           = values[4] + "-" + values[5] + "-" + values[6];
            if (Convert.ToInt32(values[4]) == 0 ||
                Convert.ToInt32(values[5]) == 0 ||
                Convert.ToInt32(values[6]) == 0)
            {
                // date = DateTime.Now.Date.ToString("yyyy-MM-dd");
                TempBellDate   = DateTime.Now;
                IsDateRequired = false;
                // Date field should be disabled.
            }
            else
            {
                if (!DateTime.TryParse(date, out TempBellDate))
                {
                    TempBellDate   = DateTime.Now;
                    IsDateRequired = false;
                }
            }

            time = Convert.ToInt32(values[1]).ToString("00") + ":" + Convert.ToInt32(values[2]).ToString("00") + ":" + Convert.ToInt32(values[3]).ToString("00");


            if (!TimeSpan.TryParse(time, out TempTime))
            {
                TempTime = DateTime.Now.TimeOfDay;
            }
            datetime = TempBellDate.ToString("yyyy-MM-dd") + " " + TempTime.ToString();

            DateTime.TryParse(datetime, out TempBellDate);

            return(TempBellDate);
        }
Esempio n. 3
0
        private string TimeConvert(TimeSpan inputTime)
        {
            string   temp;
            TimeSpan TempTime;

            if (inputTime.Hours >= 12)
            {
                if (inputTime.Hours > 12)
                {
                    TimeSpan twelveHours = new TimeSpan(12, 0, 0);
                    TempTime = inputTime.Subtract(twelveHours);
                }
                else
                {
                    TempTime = inputTime;
                }
                temp = TempTime.ToString(@"hh\:mm") + "PM";
            }
            else
            {
                temp = inputTime.ToString(@"hh\:mm") + "AM";
            }
            return(temp);
        }
Esempio n. 4
0
        /// <summary>
        /// 获取我审批过的单据
        /// </summary>
        /// <param name="Type">单据类型</param>
        /// <param name="Time">时间</param>
        /// <param name="EmployeeNo">工号</param>
        /// <returns></returns>
        public object GetApprovalData(int Type, int Time, string EmployeeNo, string departmentID, string StartTime, string EndTime)
        {
            try
            {
                var TempTime1 = DateTime.Now.Date;
                var TempTime2 = DateTime.Now.Date;
                if (Time == 6)
                {
                    TempTime1 = StartTime == "" ? new DateTime(1999, 1, 1) : Convert.ToDateTime(StartTime);
                    TempTime2 = EndTime == "" ? new DateTime(2999, 1, 1) : Convert.ToDateTime(EndTime);
                }
                WorkFlowProxy.WorkFlowProxy proxy = new WorkFlowProxy.WorkFlowProxy();
                List <WorkFlowInstance>     dic   = new List <WorkFlowInstance>();
                string objectID = proxy.GetWorkFlowListByUserId(EmployeeNo, TempTime1, TempTime2, ref dic);

                if (!string.IsNullOrEmpty(objectID) && dic.Count > 0)
                {
                    List <TempTime> Mylist = new List <TempTime>();
                    foreach (var item in dic)
                    {
                        TempTime Tmp = new TempTime();
                        Tmp.Id = item._id;
                        if (item.Assignments == null)
                        {
                            item.Assignments = new List <Assignment>();
                        }
                        var model = item.Assignments.Where(c => (c.Keyword == 12002 || c.Keyword == 12003 || c.Keyword == 12005) && c.UserCode == EmployeeNo).ToList();
                        if (model != null && model.Count > 0)
                        {
                            Tmp.Time = model.Select(c => c.updatetime).LastOrDefault();
                            Mylist.Add(Tmp);
                        }
                    }
                    List <string> WorkFlowList = new List <string>();
                    foreach (var item in Mylist)
                    {
                        WorkFlowList.Add(item.Id.ToString());
                    }

                    switch (Type)
                    {
                    //获取所有单据(不分类型)
                    case 0:
                        List <FeeBillModelRef> AllModel = new List <FeeBillModelRef>();
                        var Temp1 = new Marisfrolg.Fee.BLL.FeeBill().GetMyProcess(EmployeeNo, WorkFlowList);
                        var Temp2 = new Marisfrolg.Fee.BLL.NoticeBill().GetMyProcess(EmployeeNo, WorkFlowList);
                        var Temp3 = new Marisfrolg.Fee.BLL.BorrowBill().GetMyProcess(EmployeeNo, WorkFlowList);
                        var Temp4 = new Marisfrolg.Fee.BLL.RefundBill().GetMyProcess(EmployeeNo, WorkFlowList);
                        foreach (var item1 in Temp1)
                        {
                            FeeBillModelRef TempModel = new FeeBillModelRef()
                            {
                                BillNo = item1.BillNo, PageName = "费用报销单", Creator = item1.Creator, Owner = item1.Owner, TotalMoney = item1.TotalMoney, StringTime = item1.CreateTime.ToString("yyyy-MM-dd"), CreateTime = item1.CreateTime, PersonInfo = new PersonInfo()
                                {
                                    DepartmentCode = item1.PersonInfo.DepartmentCode, Department = item1.PersonInfo.Department
                                }
                            };
                            var Id = MongoDB.Bson.ObjectId.Parse(item1.WorkFlowID);
                            TempModel.ExamineTime = Mylist.Where(c => c.Id == Id).Select(x => x.Time).FirstOrDefault();
                            AllModel.Add(TempModel);
                        }
                        foreach (var item2 in Temp2)
                        {
                            FeeBillModelRef TempModel = new FeeBillModelRef()
                            {
                                BillNo = item2.BillNo, PageName = "付款通知书", Creator = item2.Creator, Owner = item2.Owner, TotalMoney = item2.TotalMoney, StringTime = item2.CreateTime.ToString("yyyy-MM-dd"), CreateTime = item2.CreateTime, PersonInfo = new PersonInfo()
                                {
                                    DepartmentCode = item2.PersonInfo.DepartmentCode, Department = item2.PersonInfo.Department
                                }
                            };
                            var Id = MongoDB.Bson.ObjectId.Parse(item2.WorkFlowID);
                            TempModel.ExamineTime = Mylist.Where(c => c.Id == Id).Select(x => x.Time).FirstOrDefault();
                            AllModel.Add(TempModel);
                        }
                        foreach (var item3 in Temp3)
                        {
                            FeeBillModelRef TempModel = new FeeBillModelRef()
                            {
                                BillNo = item3.BillNo, PageName = "借款单", Creator = item3.Creator, Owner = item3.Owner, TotalMoney = item3.TotalMoney, StringTime = item3.CreateTime.ToString("yyyy-MM-dd"), CreateTime = item3.CreateTime, PersonInfo = new PersonInfo()
                                {
                                    DepartmentCode = item3.PersonInfo.DepartmentCode, Department = item3.PersonInfo.Department
                                }
                            };
                            var Id = MongoDB.Bson.ObjectId.Parse(item3.WorkFlowID);
                            TempModel.ExamineTime = Mylist.Where(c => c.Id == Id).Select(x => x.Time).FirstOrDefault();
                            AllModel.Add(TempModel);
                        }
                        foreach (var item4 in Temp4)
                        {
                            FeeBillModelRef TempModel = new FeeBillModelRef()
                            {
                                BillNo = item4.BillNo, PageName = item4.RefundType.ToUpper() == "CASH" ? "现金还款" : "费用单还款", Creator = item4.Creator, Owner = item4.Owner, TotalMoney = item4.RealRefundMoney, StringTime = item4.CreateTime.ToString("yyyy-MM-dd"), CreateTime = item4.CreateTime, PersonInfo = new PersonInfo()
                                {
                                    DepartmentCode = item4.PersonInfo.DepartmentCode, Department = item4.PersonInfo.Department
                                }
                            };
                            var Id = MongoDB.Bson.ObjectId.Parse(item4.WorkFlowID);
                            TempModel.ExamineTime = Mylist.Where(c => c.Id == Id).Select(x => x.Time).FirstOrDefault();
                            AllModel.Add(TempModel);
                        }
                        if (departmentID == "0")
                        {
                            AllModel = AllModel.Where(c => c.ExamineTime.Date >= TempTime1 && c.ExamineTime.Date <= TempTime2).ToList();
                        }
                        else
                        {
                            AllModel = AllModel.Where(c => c.ExamineTime.Date >= TempTime1 && c.ExamineTime.Date <= TempTime2 && c.PersonInfo.DepartmentCode == departmentID).ToList();
                        }

                        return(AllModel.OrderByDescending(c => c.ExamineTime).ToList());

                    //未审批的费用报销单
                    case 1:
                        var FeeModel = new Marisfrolg.Fee.BLL.FeeBill().GetMyProcess(EmployeeNo, WorkFlowList);
                        List <Marisfrolg.Fee.Models.FeeBillModelRef> RefList = new List <Models.FeeBillModelRef>();
                        foreach (var item in FeeModel)
                        {
                            Marisfrolg.Fee.Models.FeeBillModelRef RefModel = new Models.FeeBillModelRef();
                            RefModel = item.MapTo <FeeBillModel, FeeBillModelRef>();
                            MongoDB.Bson.ObjectId id = MongoDB.Bson.ObjectId.Parse(RefModel.WorkFlowID);
                            RefModel.StringTime  = RefModel.CreateTime.ToString("yyyy-MM-dd");
                            RefModel.PageName    = "费用报销单";
                            RefModel.ExamineTime = Mylist.Where(c => c.Id == id).Select(x => x.Time).FirstOrDefault();
                            RefList.Add(RefModel);
                        }
                        if (departmentID == "0")
                        {
                            RefList = RefList.Where(c => c.ExamineTime.Date >= TempTime1 && c.ExamineTime.Date <= TempTime2).ToList();
                        }
                        else
                        {
                            RefList = RefList.Where(c => c.ExamineTime.Date >= TempTime1 && c.ExamineTime.Date <= TempTime2 && c.PersonInfo.DepartmentCode == departmentID).ToList();
                        }
                        return(RefList.OrderByDescending(c => c.ExamineTime).ToList());

                    //未审批的付款通知书
                    case 2:
                        var NoticeModel = new Marisfrolg.Fee.BLL.NoticeBill().GetMyProcess(EmployeeNo, WorkFlowList);
                        List <Marisfrolg.Fee.Models.NoticeBillModelRef> NoticeRefList = new List <Models.NoticeBillModelRef>();
                        foreach (var item in NoticeModel)
                        {
                            Marisfrolg.Fee.Models.NoticeBillModelRef RefModel = new Models.NoticeBillModelRef();
                            RefModel = item.MapTo <NoticeBillModel, NoticeBillModelRef>();
                            MongoDB.Bson.ObjectId id = MongoDB.Bson.ObjectId.Parse(RefModel.WorkFlowID);
                            RefModel.StringTime  = RefModel.CreateTime.ToString("yyyy-MM-dd");
                            RefModel.PageName    = "付款通知书";
                            RefModel.ExamineTime = Mylist.Where(c => c.Id == id).Select(x => x.Time).FirstOrDefault();
                            NoticeRefList.Add(RefModel);
                        }
                        if (departmentID == "0")
                        {
                            NoticeRefList = NoticeRefList.Where(c => c.ExamineTime.Date >= TempTime1 && c.ExamineTime.Date <= TempTime2).ToList();
                        }
                        else
                        {
                            NoticeRefList = NoticeRefList.Where(c => c.ExamineTime.Date >= TempTime1 && c.ExamineTime.Date <= TempTime2 && c.PersonInfo.DepartmentCode == departmentID).ToList();
                        }
                        return(NoticeRefList.OrderByDescending(c => c.ExamineTime).ToList());

                    //未审批的借款单
                    case 3:
                        var BorrowModel = new Marisfrolg.Fee.BLL.BorrowBill().GetMyProcess(EmployeeNo, WorkFlowList);
                        List <Marisfrolg.Fee.Models.BorrowBillModelRef> BorrowRefList = new List <Models.BorrowBillModelRef>();
                        foreach (var item in BorrowModel)
                        {
                            Marisfrolg.Fee.Models.BorrowBillModelRef RefModel = new Models.BorrowBillModelRef();
                            RefModel = item.MapTo <BorrowBillModel, BorrowBillModelRef>();
                            MongoDB.Bson.ObjectId id = MongoDB.Bson.ObjectId.Parse(RefModel.WorkFlowID);
                            RefModel.StringTime  = RefModel.CreateTime.ToString("yyyy-MM-dd");
                            RefModel.PageName    = "借款单";
                            RefModel.ExamineTime = Mylist.Where(c => c.Id == id).Select(x => x.Time).FirstOrDefault();
                            BorrowRefList.Add(RefModel);
                        }
                        if (departmentID == "0")
                        {
                            BorrowRefList = BorrowRefList.Where(c => c.ExamineTime.Date >= TempTime1 && c.ExamineTime.Date <= TempTime2).ToList();
                        }
                        else
                        {
                            BorrowRefList = BorrowRefList.Where(c => c.ExamineTime.Date >= TempTime1 && c.ExamineTime.Date <= TempTime2 && c.PersonInfo.DepartmentCode == departmentID).ToList();
                        }
                        return(BorrowRefList.OrderByDescending(c => c.ExamineTime).ToList());

                    //未审批的借款单
                    case 4:
                        var RefundModel = new Marisfrolg.Fee.BLL.RefundBill().GetMyProcess(EmployeeNo, WorkFlowList);
                        List <Marisfrolg.Fee.Models.RefundBillModelRef> RefundRefList = new List <Models.RefundBillModelRef>();
                        foreach (var item in RefundModel)
                        {
                            Marisfrolg.Fee.Models.RefundBillModelRef RefModel = new Models.RefundBillModelRef();
                            RefModel = item.MapTo <RefundBillModel, RefundBillModelRef>();
                            MongoDB.Bson.ObjectId id = MongoDB.Bson.ObjectId.Parse(RefModel.WorkFlowID);
                            RefModel.TotalMoney  = RefModel.RealRefundMoney;
                            RefModel.StringTime  = RefModel.CreateTime.ToString("yyyy-MM-dd");
                            RefModel.PageName    = RefModel.RefundType.ToUpper() == "CASH" ? "现金还款" : "费用单还款";
                            RefModel.ExamineTime = Mylist.Where(c => c.Id == id).Select(x => x.Time).FirstOrDefault();
                            RefundRefList.Add(RefModel);
                        }
                        if (departmentID == "0")
                        {
                            RefundRefList = RefundRefList.Where(c => c.ExamineTime.Date >= TempTime1 && c.ExamineTime.Date <= TempTime2).ToList();
                        }
                        else
                        {
                            RefundRefList = RefundRefList.Where(c => c.ExamineTime.Date >= TempTime1 && c.ExamineTime.Date <= TempTime2 && c.PersonInfo.DepartmentCode == departmentID).ToList();
                        }
                        return(RefundRefList.OrderBy(c => c.ExamineTime).ToList());

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("获取我审批过的单据失败:" + ex.ToString() + "," + System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
            return(null);
        }