示例#1
0
        protected decimal?searchRate       = null; // 该员工的实际的费率
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var thisId = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(thisId))
                {
                    thisEntry = new sdk_work_entry_dal().FindNoDeleteById(long.Parse(thisId));
                    if (thisEntry != null)
                    {
                        thisTask = new sdk_task_dal().FindNoDeleteById(thisEntry.task_id);
                    }
                }

                if (thisEntry == null || thisTask == null)
                {
                    Response.Write("<script>alert('未找到该工时信息!');window.close();self.opener.location.reload();</script>");
                }
                else
                {
                    if (thisEntry.contract_id != null)
                    {
                        var thisObject = new sdk_work_entry_dal().GetSingle($"select f_get_labor_rate({(long)thisEntry.contract_id},{thisEntry.cost_code_id.ToString()},{thisEntry.role_id.ToString()})");
                        if (thisObject != null)
                        {
                            searchRate = (decimal)thisObject;
                        }
                    }
                }
            }
            catch (Exception)
            {
                Response.End();
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var id = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    thisEntry = new sdk_work_entry_dal().FindNoDeleteById(long.Parse(id));
                }
                if (thisEntry == null)
                {
                    Response.End();
                }
                else
                {
                    if (thisEntry.cost_code_id != null)
                    {
                        thisCost = new d_cost_code_dal().FindNoDeleteById((long)thisEntry.cost_code_id);
                        thisRate = new ContractRateBLL().GetRateByCodeAndRole((long)thisEntry.cost_code_id, (long)thisEntry.role_id);
                    }
                    thisTask = new sdk_task_dal().FindNoDeleteById(thisEntry.task_id);

                    if (thisTask != null && thisTask.project_id != null)
                    {
                        thisProject = new pro_project_dal().FindNoDeleteById((long)thisTask.project_id);
                        if (thisProject != null)
                        {
                            thisAccount = new CompanyBLL().GetCompany(thisProject.account_id);
                        }
                    }
                    if (thisEntry.contract_id != null)
                    {
                        thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisEntry.contract_id);
                    }
                }
            }
            catch (Exception)
            {
                Response.End();
            }
        }
示例#3
0
        protected bool noTime = false;      // 可以不输入开始结束时间(根据系统设置进行判断)
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //  是否需要输入开始结束时间
                var isNeedTimeString = Request.QueryString["NoTime"];
                var noTimeSet        = new SysSettingBLL().GetSetById(SysSettingEnum.SDK_ENTRY_REQUIRED);
                if (!string.IsNullOrEmpty(isNeedTimeString))
                {
                    if (noTimeSet != null && noTimeSet.setting_value == "0")
                    {
                        noTime = true;
                    }
                }
                var callId = Request.QueryString["callId"];
                if (!string.IsNullOrEmpty(callId))
                {
                    thisCall = new sdk_service_call_dal().FindNoDeleteById(long.Parse(callId));
                }
                thisUser = new sys_resource_dal().FindNoDeleteById(GetLoginUserId());
                var resList = dic.FirstOrDefault(_ => _.Key == "sys_resource").Value as List <DictionaryEntryDto>;
                if (!IsPostBack)
                {
                    resource_id.DataTextField  = "show";
                    resource_id.DataValueField = "val";
                    var  entryProxySet = new SysSettingBLL().GetValueById(SysSettingEnum.SDK_ENTRY_PROXY);
                    bool isAgent       = false;
                    if (entryProxySet == ((int)DicEnum.PROXY_TIME_ENTRY.DISABLED).ToString())
                    {
                        if (resList != null && resList.Count > 0)
                        {
                            resList = resList.Where(_ => _.val == LoginUserId.ToString()).ToList();
                        }
                    }
                    else
                    {
                        var agentResList = new UserResourceBLL().GetAgentUser(LoginUserId, out isAgent);
                        if (agentResList != null && agentResList.Count > 0)
                        {
                            resList = (from a in agentResList
                                       select new DictionaryEntryDto()
                            {
                                val = a.id.ToString(), show = a.name
                            }).ToList();
                        }
                    }
                    resource_id.DataSource    = resList;
                    resource_id.SelectedValue = LoginUserId.ToString();
                    resource_id.DataBind();

                    var statusList = dic.FirstOrDefault(_ => _.Key == "ticket_status").Value as List <DictionaryEntryDto>;
                    //statusList.Remove(statusList.FirstOrDefault(_=>_.val==((int)DicEnum.TICKET_STATUS.NEW).ToString()));
                    status_id.DataTextField  = "show";
                    status_id.DataValueField = "val";
                    status_id.DataSource     = statusList;
                    status_id.DataBind();


                    cost_code_id.DataTextField  = "name";
                    cost_code_id.DataValueField = "id";
                    cost_code_id.DataSource     = new d_cost_code_dal().GetCostCodeByWhere((int)DicEnum.COST_CODE_CATE.GENERAL_ALLOCATION_CODE);
                    cost_code_id.DataBind();

                    notify_id.DataTextField  = "name";
                    notify_id.DataValueField = "id";
                    notify_id.DataSource     = new sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.TICKET_TIME_ENTRY_CREATED_EDITED);
                    notify_id.DataBind();
                }

                var taskId = Request.QueryString["task_id"];
                if (!string.IsNullOrEmpty(taskId))
                {
                    thisTask = new sdk_task_dal().FindNoDeleteById(long.Parse(taskId));
                }

                var id = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    thisWorkEntry = new sdk_work_entry_dal().FindNoDeleteById(long.Parse(id));
                    if (thisWorkEntry != null)
                    {
                        if (thisWorkEntry.approve_and_post_date != null || thisWorkEntry.approve_and_post_user_id != null)
                        {
                            Response.Write("<script>alert('审批提交的工时不可以更改!');window.close();</script>");
                            Response.End();
                        }

                        if (!resList.Any(_ => _.val == thisWorkEntry.create_user_id.ToString()))
                        {
                            Response.Write("<script>alert('系统设置不能代理操作!');window.close();</script>");
                            return;
                        }
                        if (thisWorkEntry.end_time == null && noTimeSet != null && noTimeSet.setting_value == "0")
                        {
                            noTime = true;
                        }
                        entryList = new sdk_work_entry_dal().GetBatchList(thisWorkEntry.batch_id);
                        isAdd     = false;
                        thisTask  = new sdk_task_dal().FindNoDeleteById(thisWorkEntry.task_id);
                        if (!IsPostBack)
                        {
                            resource_id.ClearSelection();
                            resource_id.SelectedValue  = ((long)thisWorkEntry.resource_id).ToString();
                            cost_code_id.SelectedValue = ((long)thisWorkEntry.cost_code_id).ToString();
                            // status_id.SelectedValue = ((long)thisWorkEntry.)
                            // thisTask  = new crm_account_dal().FindNoDeleteById(thisWorkEntry.);
                        }

                        if (thisWorkEntry.contract_id != null)
                        {
                            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisWorkEntry.contract_id);
                        }
                        if (!IsPostBack)
                        {
                            isBilled.Checked  = thisWorkEntry.is_billable == 0;
                            ShowOnInv.Checked = thisWorkEntry.show_on_invoice == 1;
                            if (isBilled.Checked)
                            {
                                ShowOnInv.Enabled = true;
                            }
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('工时已被删除!')window.close();</script>");
                        Response.End();
                    }
                }
                #region 根据批次获取相关工时
                //var batchId = Request.QueryString["batchId"];
                //if (!string.IsNullOrEmpty(batchId))
                //{
                //    entryList = new sdk_work_entry_dal().GetBatchList(long.Parse(batchId));
                //    if(entryList!=null&& entryList.Count > 0)
                //    {
                //        thisWorkEntry = entryList[0];
                //        if (thisWorkEntry.approve_and_post_date != null || thisWorkEntry.approve_and_post_user_id != null)
                //        {
                //            Response.Write("<script>alert('审批提交的工时不可以更改!');window.close();</script>");
                //            Response.End();
                //        }

                //        if (!resList.Any(_ => _.val == thisWorkEntry.create_user_id.ToString()))
                //        {
                //            Response.Write("<script>alert('系统设置不能代理操作!')window.close();</script>");
                //            Response.End();
                //        }
                //        if (thisWorkEntry.end_time == null && noTimeSet != null && noTimeSet.setting_value == "0")
                //        {
                //            noTime = true;
                //        }
                //        entryList = new sdk_work_entry_dal().GetBatchList(thisWorkEntry.batch_id);
                //        isAdd = false;
                //        thisTask = new sdk_task_dal().FindNoDeleteById(thisWorkEntry.task_id);
                //        if (!IsPostBack)
                //        {
                //            resource_id.SelectedValue = ((long)thisWorkEntry.resource_id).ToString();
                //            cost_code_id.SelectedValue = ((long)thisWorkEntry.cost_code_id).ToString();
                //            // status_id.SelectedValue = ((long)thisWorkEntry.)
                //            // thisTask  = new crm_account_dal().FindNoDeleteById(thisWorkEntry.);

                //        }

                //        if (thisWorkEntry.contract_id != null)
                //        {
                //            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisWorkEntry.contract_id);
                //        }
                //        if (!IsPostBack)
                //        {
                //            isBilled.Checked = thisWorkEntry.is_billable == 0;
                //            ShowOnInv.Checked = thisWorkEntry.show_on_invoice == 1;
                //            if (isBilled.Checked)
                //            {
                //                ShowOnInv.Enabled = true;
                //            }
                //        }
                //    }
                //}
                #endregion
                if (thisTask != null)
                {
                    v_task      = new v_task_all_dal().FindById(thisTask.id);
                    thisProjetc = new pro_project_dal().FindNoDeleteById((long)thisTask.project_id);
                    if (thisProjetc != null)
                    {
                        thisAccount = new crm_account_dal().FindNoDeleteById(thisProjetc.account_id);
                        if (!IsPostBack)
                        {
                            status_id.SelectedValue = thisTask.status_id.ToString();
                        }
                    }
                }
                // 项目关联合同,并且合同中设置-工时录入需要输入开始结束时间
                if (thisProjetc != null && thisProjetc.contract_id != null)
                {
                    var thisCttContract = new ctt_contract_dal().FindNoDeleteById((long)thisProjetc.contract_id);
                    if (thisCttContract != null)
                    {
                        if (thisCttContract.timeentry_need_begin_end == 1)
                        {
                            noTime = false;
                        }
                    }
                }

                if (thisCall != null)
                {
                    showStartDate = EMT.Tools.Date.DateHelper.ConvertStringToDateTime(thisCall.start_time);
                    showEndDate   = EMT.Tools.Date.DateHelper.ConvertStringToDateTime(thisCall.end_time);
                }
                if (!string.IsNullOrEmpty(Request.QueryString["chooseDate"]))
                {
                    showStartDate = DateTime.Parse(Request.QueryString["chooseDate"]);
                    showEndDate   = DateTime.Parse(Request.QueryString["chooseDate"]);
                }
            }
            catch (Exception msg)
            {
                Response.Write($"<script>alert('{msg.Message}');window.close();</script>");
            }
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            long batchId;

            if (long.TryParse(Request.QueryString["id"], out batchId))
            {
                isAdd = false;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["resourceId"]))
            {
                resourceId = long.Parse(Request.QueryString["resourceId"]);
            }
            else
            {
                resourceId = LoginUserId;
            }

            var entryProxySet = new SysSettingBLL().GetValueById(SysSettingEnum.SDK_ENTRY_PROXY);

            if (entryProxySet == ((int)DicEnum.PROXY_TIME_ENTRY.ENABLED_TIMESHEET_APPROVERS).ToString())
            {
                showResource = true;
            }

            if (string.IsNullOrEmpty(Request.QueryString["startDate"]))
            {
                startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            }
            else
            {
                startDate = DateTime.Parse(Request.QueryString["startDate"]);
            }
            if (!isAdd)     // 编辑工时的开始日期
            {
                workEntryList = bll.GetWorkEntryByBatchId(batchId);
                if (workEntryList.Count <= 0)
                {
                    Response.Write("<script>alert('工时不存在');window.close();</script>");
                    Response.End();
                    return;
                }
                startDate  = Tools.Date.DateHelper.TimeStampToUniversalDateTime(workEntryList[0].start_time.Value);
                resourceId = workEntryList[0].resource_id.Value;
            }
            if (startDate.DayOfWeek != DayOfWeek.Monday)
            {
                if (startDate.DayOfWeek == DayOfWeek.Sunday)
                {
                    startDate = startDate.AddDays(-6);
                }
                else
                {
                    startDate = startDate.AddDays((int)DayOfWeek.Monday - (int)startDate.DayOfWeek);
                }
            }
            resourceName = new UserResourceBLL().GetResourceById(resourceId).name;

            var costCodeList = bll.GetTimeCostCodeList();

            if (!IsPostBack)
            {
                if (isAdd)
                {
                    costCodeName.Visible        = false;
                    cost_code_id.DataValueField = "id";
                    cost_code_id.DataTextField  = "name";
                    cost_code_id.DataSource     = costCodeList;
                    cost_code_id.DataBind();
                }
                else
                {
                    cost_code_id.Visible = false;
                    costCodeName.Visible = true;
                    costCodeName.Text    = costCodeList.Find(_ => _.id == workEntryList[0].task_id).name;

                    DateTime dt   = new DateTime(startDate.Ticks);
                    var      find = workEntryList.Find(_ => _.start_time == Tools.Date.DateHelper.ToUniversalTimeStamp(dt));
                    if (find != null)
                    {
                        monday.Text       = find.hours_billed.Value.ToString();
                        mondayInter.Value = find.internal_notes;
                        mondayNodes.Value = find.summary_notes;
                    }
                    dt   = dt.AddDays(1);
                    find = workEntryList.Find(_ => _.start_time == Tools.Date.DateHelper.ToUniversalTimeStamp(dt));
                    if (find != null)
                    {
                        tuesday.Text       = find.hours_billed.Value.ToString();
                        tuesdayInter.Value = find.internal_notes;
                        tuesdayNodes.Value = find.summary_notes;
                    }
                    dt   = dt.AddDays(1);
                    find = workEntryList.Find(_ => _.start_time == Tools.Date.DateHelper.ToUniversalTimeStamp(dt));
                    if (find != null)
                    {
                        wednesday.Text       = find.hours_billed.Value.ToString();
                        wednesdayInter.Value = find.internal_notes;
                        wednesdayNodes.Value = find.summary_notes;
                    }
                    dt   = dt.AddDays(1);
                    find = workEntryList.Find(_ => _.start_time == Tools.Date.DateHelper.ToUniversalTimeStamp(dt));
                    if (find != null)
                    {
                        thursday.Text       = find.hours_billed.Value.ToString();
                        thursdayInter.Value = find.internal_notes;
                        thursdayNodes.Value = find.summary_notes;
                    }
                    dt   = dt.AddDays(1);
                    find = workEntryList.Find(_ => _.start_time == Tools.Date.DateHelper.ToUniversalTimeStamp(dt));
                    if (find != null)
                    {
                        friday.Text       = find.hours_billed.Value.ToString();
                        fridayInter.Value = find.internal_notes;
                        fridayNodes.Value = find.summary_notes;
                    }
                    dt   = dt.AddDays(1);
                    find = workEntryList.Find(_ => _.start_time == Tools.Date.DateHelper.ToUniversalTimeStamp(dt));
                    if (find != null)
                    {
                        saturday.Text       = find.hours_billed.Value.ToString();
                        saturdayInter.Value = find.internal_notes;
                        saturdayNodes.Value = find.summary_notes;
                    }
                    dt   = dt.AddDays(1);
                    find = workEntryList.Find(_ => _.start_time == Tools.Date.DateHelper.ToUniversalTimeStamp(dt));
                    if (find != null)
                    {
                        sunday.Text       = find.hours_billed.Value.ToString();
                        sundayInter.Value = find.internal_notes;
                        sundayNodes.Value = find.summary_notes;
                    }
                }
                if (showResource)
                {
                    var resList = new UserResourceBLL().GetResourceList();
                    resource_id.DataValueField = "val";
                    resource_id.DataTextField  = "show";
                    resource_id.DataSource     = resList;
                    resource_id.DataBind();
                    if (resList.Exists(_ => _.val == resourceId.ToString()))
                    {
                        resource_id.SelectedValue = resourceId.ToString();
                    }
                }
                notify_tmpl_id.DataTextField  = "name";
                notify_tmpl_id.DataValueField = "id";
                notify_tmpl_id.DataSource     = new DAL.sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.TICKET_TIME_ENTRY_CREATED_EDITED);
                notify_tmpl_id.DataBind();
            }
            else
            {
                List <string> weNames = new List <string> {
                    "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
                };
                if (isAdd && showResource)
                {
                    resourceId = long.Parse(resource_id.SelectedValue);
                }

                var weList = new List <sdk_work_entry>();
                for (int i = 0; i < weNames.Count; i++)
                {
                    decimal hours_worked;
                    if (!decimal.TryParse(Request.Form[weNames[i]], out hours_worked))
                    {
                        continue;
                    }
                    sdk_work_entry we = new sdk_work_entry();
                    if (isAdd)
                    {
                        long taskId = long.Parse(cost_code_id.SelectedValue);
                        we.task_id      = taskId;
                        we.cost_code_id = taskId;
                    }
                    else
                    {
                        we.batch_id = batchId;
                    }
                    we.resource_id     = resourceId;
                    we.start_time      = Tools.Date.DateHelper.ToUniversalTimeStamp(startDate.AddDays(i));
                    we.end_time        = we.start_time;
                    we.hours_worked    = hours_worked;
                    we.hours_billed    = hours_worked;
                    we.offset_hours    = 0;
                    we.internal_notes  = Request.Form[weNames[i] + "Inter"];
                    we.summary_notes   = Request.Form[weNames[i] + "Nodes"];
                    we.is_billable     = 0;
                    we.show_on_invoice = 0;
                    weList.Add(we);
                }

                if (isAdd)
                {
                    bll.AddWorkEntry(weList, LoginUserId);
                }
                else if (!bll.EditWorkEntry(weList, batchId, LoginUserId))
                {
                    Response.Write("<script>alert('工时审批提交后不能编辑');</script>");
                    return;
                }

                if (Request.Form["subAct"] == "SaveClose")
                {
                    Response.Write("<script>window.close();self.opener.location.reload();</script>");
                    Response.End();
                }
                else
                {
                    Response.Write("<script>window.location.href='RegularTimeAddEdit';self.opener.location.reload();</script>");
                    Response.End();
                }
            }
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                showResList = new UserResourceBLL().GetAgentUser(LoginUserId, out isAllowAgentRes);

                isComplete = !string.IsNullOrEmpty(Request.QueryString["is_complete"]);
                if (!IsPostBack)
                {
                    GetPageDataBind();
                }
                var ticket_id = Request.QueryString["ticket_id"];
                if (!string.IsNullOrEmpty(ticket_id))
                {
                    thisTicket = new sdk_task_dal().FindNoDeleteById(long.Parse(ticket_id));
                    if (thisTicket != null)
                    {
                        if (thisTicket.contact_id != null)
                        {
                            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisTicket.contract_id);
                        }
                        if (thisTicket.cost_code_id != null)
                        {
                            cost_code_id.SelectedValue = thisTicket.cost_code_id.ToString();
                        }
                    }
                }
                var service_id = Request.QueryString["service_id"];
                if (!string.IsNullOrEmpty(service_id))
                {
                    thisCall = new sdk_service_call_dal().FindNoDeleteById(long.Parse(service_id));
                }
                var id = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    ticketLabour = new sdk_work_entry_dal().FindNoDeleteById(long.Parse(id));
                    if (ticketLabour != null)
                    {
                        isAdd      = false;
                        thisTicket = new sdk_task_dal().FindNoDeleteById(ticketLabour.task_id);
                        if (ticketLabour.resource_id != null)
                        {
                            resource_id.SelectedValue = ((long)ticketLabour.resource_id).ToString();
                        }
                        if (ticketLabour.cost_code_id != null)
                        {
                            cost_code_id.ClearSelection();
                            cost_code_id.SelectedValue = ticketLabour.cost_code_id.ToString();
                        }
                        if (ticketLabour.role_id != null)
                        {
                            role_id.SelectedValue = ticketLabour.role_id.ToString();
                        }
                        if (ticketLabour.contract_id != null)
                        {
                            thisContract = new ctt_contract_dal().FindNoDeleteById((long)ticketLabour.contract_id);
                        }
                    }
                }

                if (thisTicket != null)
                {
                    thisAccount = new CompanyBLL().GetCompany(thisTicket.account_id);
                    if (!isComplete)
                    {
                        status_id.SelectedValue = (thisTicket.status_id).ToString();
                    }
                    else
                    {
                        status_id.SelectedValue = ((int)DicEnum.TICKET_STATUS.DONE).ToString();
                    }
                }
                else
                {
                    Response.Write("<script>alert('未查询到该工单信息!');window.close();</script>");
                }

                if (thisAccount != null)
                {
                    accAlert = new crm_account_alert_dal().FindAlert(thisAccount.id, DicEnum.ACCOUNT_ALERT_TYPE.COMPANY_DETAIL_ALERT);
                }
            }
            catch (Exception msg)
            {
                Response.Write("<script>alert('" + msg.Message + "');window.close();</script>");
            }
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            long id = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["id"]) && long.TryParse(Request.QueryString["id"], out id))
            {
                deduction = invBll.GetDeduction(id);
            }

            //if (deduction == null)
            //{
            //    Response.Write("<script>alert('未获取到相关条目');window.close();</script>");
            //}
            long blockId = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["blockId"]) && long.TryParse(Request.QueryString["blockId"], out blockId))
            {
                block = new ContractBlockBLL().GetBlockById(blockId);
            }

            if (deduction != null)
            {
                vItem   = new DAL.v_widget_posted_item_dal().FindById(deduction.id);
                rate    = vItem?.rate;
                account = new CompanyBLL().GetCompany(deduction.account_id);
                if (deduction.contract_id != null)
                {
                    contract = new ContractBLL().GetContract((long)deduction.contract_id);
                }
                if (deduction.task_id != null)
                {
                    task = new TicketBLL().GetTask((long)deduction.task_id);
                }
                labour = new WorkEntryBLL().GetEntryById((long)deduction.object_id);
                if (vItem?.tax_category_id != null && vItem?.tax_region_id != null)
                {
                    var thisTax = new DAL.d_tax_region_cate_dal().GetSingleTax((long)vItem?.tax_region_id, (long)vItem?.tax_category_id);
                    taxRate = thisTax?.total_effective_tax_rate;
                }
                if (vItem?.resource_id != null)
                {
                    resource = new UserResourceBLL().GetResourceById((long)vItem.resource_id);
                }
                if (deduction.contract_block_id != null)
                {
                    dedBlock = new ContractBlockBLL().GetBlockById((long)deduction.contract_block_id);
                }
            }
            if (block != null)
            {
                contract = new ContractBLL().GetContract(block.contract_id);
                if (contract != null)
                {
                    account      = new CompanyBLL().GetCompany(contract.account_id);
                    contractType = new GeneralBLL().GetSingleGeneral(contract.type_id);
                }
            }
            if (block == null && deduction == null)
            {
                Response.Write("<script>alert('未获取到相关条目');window.close();</script>");
            }
        }