protected void AddSalary_Submit(object sender, EventArgs e)
        {
            DalOperationAboutSalaryEntry dal = new DalOperationAboutSalaryEntry();
            DalOperationAboutTeacher dalt = new DalOperationAboutTeacher();
            DalOperationAboutCourses dalc = new DalOperationAboutCourses();

            string teacherNo = this.TeacherId.Value;
            string termTag = this.SalaryTermTag.SelectedValue;
            string salaryMonth = this.SalaryMonth.Value;
            int teacherType = int.Parse(this.teacherType.Value.Trim());
            int salaryEntryStatus = 0;

            List<SalaryEntry> salaryEntries = dal.GetSalaryEntrys(teacherNo, termTag, salaryMonth, teacherType, salaryEntryStatus);
            if (salaryEntries != null && salaryEntries.Count != 0)
            {
                Javascript.Alert("本月已为该教师添加过薪酬信息,请核对信息后再次录入!", Page);
            }
            else {
                SalaryEntry salaryEntry = new SalaryEntry();

                TeachersList teacher = new TeachersList
                {
                    teacherNo = teacherNo
                };

                Courses course = new Courses
                {
                    courseNo = this.CourseId.Value
                };

                salaryEntry.teacher = teacher;
                salaryEntry.course = course;
                salaryEntry.atCourseType = atCourseType.Value;
                salaryEntry.termTag = termTag;
                salaryEntry.salaryMonth = salaryMonth;
                salaryEntry.teacherCostWithTax = float.Parse(this.TeacherSalaryCostWithTax.Text);
                salaryEntry.teacherCostWithoutTax = float.Parse(this.TeacherSalaryCostWithoutTax.Text);
                salaryEntry.teacherTotalCost = float.Parse(this.TeacherTotalCost.Text);

                salaryEntry.SetSalaryInItemValueList(this.InSalaryItemValueList.Value, false);
                salaryEntry.SetSalaryOutItemValueList(this.OutSalaryItemValueList.Value, false);
                salaryEntry.memo = this.SalaryEntryMemo.Text.Trim();
                salaryEntry.teacherType = teacherType;

                dal.AddSalaryEntry(salaryEntry);
                Javascript.RefreshParentWindow("/Administrator/SalaryManage.aspx?fragment=5", Page);
            }
        }
示例#2
0
        private void BuildInSalaryItemValueList(SalaryEntry salaryEntry)
        {
            DataListItemCollection itemCollection = this.InSalaryItemList.Items;
            string salaryItemValueList = "";
            float totalSalaryValue = 0;
            float teacherCostWithoutTax = 0;
            float teacherCostWithTax = 0;
            foreach (DataListItem item in itemCollection)
            {
                string itemId = ((HiddenField)item.FindControl("in" + "SalaryItemId")).Value;

                string salaryStandard;
                if (((DropDownList)item.FindControl("InSalaryItemStandard_DropDownList")).Visible)
                {
                    salaryStandard = ((DropDownList)item.FindControl("InSalaryItemStandard_DropDownList")).SelectedValue;
                }
                else {
                    salaryStandard = ((TextBox)item.FindControl("in" + "SalaryStandard")).Text;
                }

                string salaryUnit = ((TextBox)item.FindControl("in" + "SalaryUnit")).Text;

                string salaryAdjust = ((TextBox)item.FindControl("in" + "salaryAdjust")).Text;

                float salaryValue = float.Parse(salaryStandard) * float.Parse(salaryUnit) * float.Parse(salaryAdjust);

                bool hasTax = bool.Parse(((HiddenField)item.FindControl("InSalaryItemHasTax")).Value.Trim());

                salaryItemValueList += (itemId + ":" + salaryStandard + "," + salaryUnit + "," + salaryAdjust + ";");
                if (hasTax)
                {
                    teacherCostWithTax += salaryValue;
                }
                else
                {
                    teacherCostWithoutTax += salaryValue;
                }

            }

            if (salaryItemValueList.Length > 0)
            {
                salaryItemValueList = salaryItemValueList.Substring(0, salaryItemValueList.Length - 1);
            }

            salaryEntry.SetSalaryInItemValueList(salaryItemValueList, false);
            salaryEntry.teacherCostWithoutTax += teacherCostWithoutTax;
            salaryEntry.teacherCostWithTax += teacherCostWithTax;
            totalSalaryValue = teacherCostWithoutTax + (teacherCostWithTax - float.Parse(CommonUtility.CalculateTax(decimal.Parse(teacherCostWithTax.ToString())).ToString()));
            salaryEntry.teacherTotalCost += totalSalaryValue;

            salaryEntry.teacherCostWithoutTax = CommonUtility.ConvertFormatedFloat("{0:F2}", salaryEntry.teacherCostWithoutTax.ToString());

            salaryEntry.teacherCostWithTax = CommonUtility.ConvertFormatedFloat("{0:F2}", salaryEntry.teacherCostWithTax.ToString());

            salaryEntry.teacherTotalCost = CommonUtility.ConvertFormatedFloat("{0:F2}", salaryEntry.teacherTotalCost.ToString());
        }
        /// <summary>
        /// 从DataReader中转化并构造SalaryEntry记录集
        /// </summary>
        /// <param name="dataReader"></param>
        /// <returns></returns>
        private void BuildSalaryEntry(IDataReader dataReader, List<SalaryEntry> salaryEntries)
        {
            DalOperationAboutTeacher dalt = new DalOperationAboutTeacher();
            DalOperationAboutCourses dalc = new DalOperationAboutCourses();
            if (dataReader != null)
            {
                while (dataReader.Read())
                {
                    SalaryEntry salaryEntry = new SalaryEntry();
                    salaryEntry.salaryEntryId = int.Parse(dataReader["salaryEntryId"].ToString().Trim());
                    TeachersList teacher = dalt.GetTeacherById(dataReader["teacherNo"].ToString().Trim());
                    salaryEntry.teacher = teacher;
                    salaryEntry.teacherType = int.Parse(dataReader["teacherType"].ToString().Trim());
                    salaryEntry.termTag = dataReader["termTag"].ToString().Trim();
                    Courses course = dalc.GetCoursesByNo(dataReader["courseNo"].ToString().Trim(), salaryEntry.termTag);
                    salaryEntry.course = course;
                    salaryEntry.atCourseType = dataReader["atCourseType"].ToString().Trim();

                    salaryEntry.SetSalaryInItemValueList(dataReader["salaryInItemValueList"].ToString().Trim(), true);
                    salaryEntry.SetSalaryOutItemValueList(dataReader["salaryOutItemValueList"].ToString().Trim(), true);
                    if (dataReader["salaryInAdjustFactor"] != null)
                    {
                        salaryEntry.salaryInAdjustFactor = float.Parse(dataReader["salaryInAdjustFactor"].ToString().Trim());
                    }

                    if (dataReader["salaryOutAdjustFactor"] != null)
                    {
                        salaryEntry.salaryOutAdjustFactor = float.Parse(dataReader["salaryOutAdjustFactor"].ToString().Trim());
                    }

                    if (dataReader["teachPeriod"] != null)
                    {
                        salaryEntry.teachPeriod = int.Parse(dataReader["teachPeriod"].ToString().Trim());
                    }

                    if (dataReader["teachAssiPeriod"] != null)
                    {
                        salaryEntry.teachAssiPeriod = int.Parse(dataReader["teachAssiPeriod"].ToString().Trim());
                    }

                    salaryEntry.teacherCostWithTax = float.Parse(dataReader["teacherCostWithTax"].ToString().Trim());
                    salaryEntry.teacherCostWithoutTax = float.Parse(dataReader["teacherCostWithoutTax"].ToString().Trim());
                    salaryEntry.teacherTotalCost = float.Parse(dataReader["teacherTotalCost"].ToString().Trim());
                    salaryEntry.salaryMonth = dataReader["salaryMonth"].ToString().Trim();
                    salaryEntry.salaryEntryStatus = int.Parse(dataReader["salaryEntryStatus"].ToString());
                    salaryEntry.createdTime = DateTime.Parse(dataReader["createdTime"].ToString().Trim());
                    salaryEntry.memo = dataReader["memo"].ToString().Trim();
                    salaryEntries.Add(salaryEntry);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                string formatedTeacherSalaryCostWithTax = CommonUtility.ConvertFormatedFloat("{0:F2}", Request["withTax"].Trim()).ToString();

                string formatedTeacherSalaryCostWithoutTax = CommonUtility.ConvertFormatedFloat("{0:F2}", Request["withoutTax"].Trim()).ToString();

                string formatedTeacherTotalCost = CommonUtility.ConvertFormatedFloat("{0:F2}", Request["totalCost"].Trim()).ToString();

                this.TeacherSalaryCostWithTax.Text = formatedTeacherSalaryCostWithTax;
                this.TeacherSalaryCostWithoutTax.Text = formatedTeacherSalaryCostWithoutTax;
                this.TeacherTotalCost.Text = formatedTeacherTotalCost;
                this.InSalaryItemValueList.Value = Request["inValueList"];
                this.OutSalaryItemValueList.Value = Request["outValueList"];

                SalaryEntry salaryEntry = new SalaryEntry();
                salaryEntry.SetSalaryInItemValueList(Request["inValueList"], true);
                salaryEntry.SetSalaryOutItemValueList(Request["outValueList"], true);

                List<SalaryItemElement> inItemElements = salaryEntry.GetSalaryInItemElements();
                List<SalaryItemElement> outItemElements = salaryEntry.GetSalaryOutItemElements();

                FullFillSalaryItemElements(inItemElements);
                FullFillSalaryItemElements(outItemElements);

                this.ShowSalaryInItems.DataSource = inItemElements;
                this.ShowSalaryOutItems.DataSource = outItemElements;

                this.ShowSalaryInItems.DataBind();
                this.ShowSalaryOutItems.DataBind();

                DataBindSearchTermTagList();

                this.TeacherId.Value = Request["tid"];
                DalOperationAboutTeacher teacherDal = new DalOperationAboutTeacher();
                TeachersList teacher = teacherDal.GetTeacherById(Request["tid"].Trim());
                this.TeacherName.Text = teacher.teacherName;

                DateTime lastMonth = DateTime.Now.Date.AddMonths(-1);
                string lastMonthString = lastMonth.Month < 10 ? "0" + lastMonth.Month.ToString() : lastMonth.Month.ToString();
                this.SalaryMonth.Value = lastMonth.Year + "-" + lastMonthString;

                this.CourseId.Value = Request["cid"];
                this.atCourseType.Value = Request["acType"];
                this.teacherType.Value = Request["teacherType"];
            }
        }
示例#5
0
        private void AddSalaryEntryDefault(TeacherSalary teacherSalary)
        {
            List<SalaryItemElement> teacherSalaryElements = teacherSalary.GetSalaryInItemElements();
            int maxMonth = 1;
            foreach(SalaryItemElement teacherSalaryElement in teacherSalaryElements){
                if (teacherSalaryElement.MonthNum > maxMonth) {
                    maxMonth = teacherSalaryElement.MonthNum;
                }
            }
            List<string> salaryInValueListForMonth = new List<string>();
            List<float> salaryWithTax = new List<float>();
            List<float> salaryWithoutTax = new List<float>();

            string salaryInValueStringForMonth;
            string singleSalaryItemValue;
            float salaryWithTaxForMonth;
            float salaryWithoutTaxForMonth;
            for (int i = 1; i <= maxMonth; i++) {
                salaryInValueStringForMonth = "";
                salaryWithTaxForMonth = 0f;
                salaryWithoutTaxForMonth = 0f;
                foreach (SalaryItemElement teacherSalaryElement in teacherSalaryElements) {
                    singleSalaryItemValue = "";

                    if (i <= teacherSalaryElement.MonthNum)
                    {
                        if (teacherSalaryElement.salaryStandard != 0)
                        {
                            singleSalaryItemValue = (teacherSalaryElement.salaryItemId + ":" + teacherSalaryElement.salaryStandard + "," + CommonUtility.ConvertFormatedFloat("{0:F2}", (teacherSalaryElement.times / teacherSalaryElement.MonthNum).ToString()) + ",1;");
                        }
                        else {
                            singleSalaryItemValue = (teacherSalaryElement.salaryItemId + ":" +
                                CommonUtility.ConvertFormatedFloat("{0:F2}", (teacherSalaryElement.itemCost / teacherSalaryElement.MonthNum).ToString()) + ",1,1;");
                            if (teacherSalaryElement.hasTax)
                            {
                                salaryWithTaxForMonth += CommonUtility.ConvertFormatedFloat("{0:F2}", (teacherSalaryElement.itemCost / teacherSalaryElement.MonthNum).ToString());
                            }
                            else {
                                salaryWithoutTaxForMonth += CommonUtility.ConvertFormatedFloat("{0:F2}", (teacherSalaryElement.itemCost / teacherSalaryElement.MonthNum).ToString());
                            }
                        }

                        salaryInValueStringForMonth += singleSalaryItemValue;
                        if (teacherSalaryElement.hasTax) {
                            salaryWithTaxForMonth += (teacherSalaryElement.salaryStandard * teacherSalaryElement.times / teacherSalaryElement.MonthNum);
                            }else{
                            salaryWithoutTaxForMonth += (teacherSalaryElement.salaryStandard * teacherSalaryElement.times / teacherSalaryElement.MonthNum);
                        }
                    }
                }
                if (!string.IsNullOrWhiteSpace(salaryInValueStringForMonth)) {
                    salaryInValueStringForMonth = salaryInValueStringForMonth.Substring(0, salaryInValueStringForMonth.Length - 1);
                    salaryInValueListForMonth.Add(salaryInValueStringForMonth);
                    salaryWithTax.Add(salaryWithTaxForMonth);
                    salaryWithoutTax.Add(salaryWithoutTaxForMonth);
                }
            }

            DalOperationAboutSalaryEntry dalse = new DalOperationAboutSalaryEntry();
            SalaryEntry salaryEntry = new SalaryEntry();
            salaryEntry.teacher = teacherSalary.teacher;
            salaryEntry.teacherType = teacherSalary.teacherType;
            salaryEntry.course = teacherSalary.course;
            salaryEntry.atCourseType = "" + teacherSalary.atCourseType;
            salaryEntry.termTag = teacherSalary.termTag;
            salaryEntry.salaryEntryStatus = 1;
            salaryEntry.memo = "本列表中的税后所得仅为假定你在苏州研究院的所有收入只有此项而计算(因为是兼职,财务默认您的基础收入已经为3500元),仅供参考!实际税后金额,以财务发放为准,有问题可以及时联系教学管理部(0512-68839206)或者财务(0512-87161163)";

            DateTime monthDateTime = DateTime.Now;

            for (int i = 0; i < salaryInValueListForMonth.Count; i++) {
                salaryEntry.SetSalaryInItemValueList(salaryInValueListForMonth[i], false);

                salaryEntry.teacherCostWithTax = CommonUtility.ConvertFormatedFloat("{0:F2}", salaryWithTax[i].ToString());
                salaryEntry.teacherCostWithoutTax = CommonUtility.ConvertFormatedFloat("{0:F2}", salaryWithoutTax[i].ToString());
                salaryEntry.teacherTotalCost = CommonUtility.ConvertFormatedFloat("{0:F2}", ((salaryEntry.teacherCostWithTax - float.Parse(CommonUtility.CalculateTax(decimal.Parse(salaryEntry.teacherCostWithTax.ToString())).ToString())) + salaryEntry.teacherCostWithoutTax).ToString());

                int monthValue = monthDateTime.Month;

                salaryEntry.salaryMonth = (monthDateTime.Year + "-" + (monthValue < 10 ? "0" + monthValue.ToString() : monthValue.ToString()));

                dalse.AddSalaryEntry(salaryEntry);
                monthDateTime = monthDateTime.AddMonths(1);
            }
        }