Пример #1
0
        /// <summary>
        /// 比较合同和工单的采购订单信息,返回合同订单号和工单的成本未审批成本数量
        /// </summary>
        private void CheckContractPurchaseOrder(HttpContext context)
        {
            var  contractId    = context.Request.QueryString["contract_id"];
            var  purchaseOrder = context.Request.QueryString["purchase_order"];
            var  ticketId      = context.Request.QueryString["ticket_id"];
            var  returnOrder   = "";
            int  count         = 0;
            bool isUpdateOrder = false;  // 是否需要更新采购订单

            if (!string.IsNullOrEmpty(contractId) && !string.IsNullOrEmpty(purchaseOrder))
            {
                var thisContract = new ctt_contract_dal().FindNoDeleteById(long.Parse(contractId));
                if (thisContract != null && !string.IsNullOrEmpty(thisContract.purchase_order_no))
                {
                    returnOrder = thisContract.purchase_order_no;

                    if (purchaseOrder != thisContract.purchase_order_no)
                    {
                        isUpdateOrder = true;
                    }
                }
            }
            if (!string.IsNullOrEmpty(ticketId))
            {
                var thisCost = new ctt_contract_cost_dal().GetListByTicketId(long.Parse(ticketId), $" and bill_status=0 and purchase_order_no='{purchaseOrder}'");
                if (thisCost != null && thisCost.Count > 0)
                {
                    count = thisCost.Count;
                }
            }
            context.Response.Write(new EMT.Tools.Serialize().SerializeJson(new { isUpdateOrder = isUpdateOrder, count = count, returnOrder = returnOrder }));
        }
Пример #2
0
        /// <summary>
        /// 从全部当前激活的合同中排除
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE Exclude(long id, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var exc      = new ctt_contract_dal();
            var exc_role = new ctt_contract_exclusion_role_dal();
            ctt_contract_exclusion_role role = new ctt_contract_exclusion_role();

            var excc = exc.FindListBySql <ctt_contract>($"select * from ctt_contract where status_id = 1 and end_date> CURDATE() and delete_time = 0");

            if (excc.Count > 0)
            {
                foreach (var i in excc)
                {
                    var exccrole = exc_role.FindListBySql <ctt_contract_exclusion_role>($"select * from ctt_contract_exclusion_role where role_id={id} and contract_id={i.id} and delete_time=0");
                    if (exccrole == null)
                    {
                        try
                        {
                            role.contract_id    = i.id;
                            role.id             = (int)(_dal.GetNextIdCom());
                            role.role_id        = id;
                            role.create_user_id = role.update_user_id = user_id;
                            role.create_time    = role.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                            exc_role.Insert(role);
                            var add_log = new sys_oper_log()
                            {
                                user_cate           = "用户",
                                user_id             = (int)user.id,
                                name                = user.name,
                                phone               = user.mobile == null ? "" : user.mobile,
                                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTRACT_EXCLUSTION_ROLE, //角色
                                oper_object_id      = role.id,                                         // 操作对象id
                                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                                oper_description    = _dal.AddValue(role),
                                remark              = "新增合同例外因素--角色"
                            };                                      // 创建日志
                            new sys_oper_log_dal().Insert(add_log); // 插入日志
                        }
                        catch
                        {
                            return(ERROR_CODE.ERROR);
                        }
                    }
                }
            }
            else
            {
                return(ERROR_CODE.CONTRACT_NO_ACTIVE);
            }
            return(ERROR_CODE.SUCCESS);
        }
Пример #3
0
        /// <summary>
        /// 获取到合同的相关属性
        /// </summary>
        /// <param name="context"></param>
        /// <param name="contract_id"></param>
        /// <param name="propertyName"></param>
        private void GetContractProperty(HttpContext context, long contract_id, string propertyName)
        {
            var contract = new ctt_contract_dal().FindNoDeleteById(contract_id);

            if (contract != null)
            {
                context.Response.Write(BaseDAL <ctt_contract> .GetObjectPropertyValue(contract, propertyName));
            }
        }
Пример #4
0
        private void ChecckCostCode(HttpContext context, long cid, long cost_code_id)
        {
            var contract = new ctt_contract_dal().FindNoDeleteById(cid);
            var result   = false;

            if (contract != null)
            {
                var def_cha = new ctt_contract_cost_default_dal().GetSinCostDef(cid, cost_code_id);
                if (def_cha != null)
                {
                    context.Response.Write(new Tools.Serialize().SerializeJson(def_cha));
                }
            }
        }
Пример #5
0
        /// <summary>
        /// 检查合同的有效期
        /// </summary>
        private void CheckContractDate(HttpContext context)
        {
            bool isExp      = false; // 是否过期
            var  contractId = context.Request.QueryString["contract_id"];

            if (!string.IsNullOrEmpty(contractId))
            {
                var thisContract = new ctt_contract_dal().FindNoDeleteById(long.Parse(contractId));
                if (thisContract != null)
                {
                    if (thisContract.start_date > DateTime.Now || thisContract.end_date < DateTime.Now)
                    {
                        isExp = true;
                    }
                }
            }
            context.Response.Write(isExp);
            // new EMT.Tools.Serialize().SerializeJson()
        }
Пример #6
0
 /// <summary>
 /// 判断报价是否包含初始费 并且 合同中是否也有初始费用
 /// </summary>
 /// <param name="context"></param>
 /// <param name="quote_id"></param>
 /// <param name="contract_id"></param>
 public void CompareSetupFee(HttpContext context, long quote_id, long contract_id)
 {
     var quote = new QuoteBLL().GetQuote(quote_id);
     var contract = new ctt_contract_dal().GetSingleContract(contract_id);
     bool isHasSetupFee = false;
     if (quote != null && contract != null)
     {
         var quoteItemList = new crm_quote_item_dal().GetQuoteItems($" and quote_id = {quote.id}");
         if (quoteItemList != null && quoteItemList.Count > 0)
         {
             var setupFeeItem = quoteItemList.Where(_ => _.type_id == (int)QUOTE_ITEM_TYPE.START_COST).ToList();
             if (setupFeeItem != null && setupFeeItem.Count > 0 && contract.setup_fee != null)
             {
                 isHasSetupFee = true;
             }
         }
     }
     context.Response.Write(isHasSetupFee);
 }
Пример #7
0
        /// <summary>
        ///  根据合同Id获取相关信息,用横线隔开
        /// </summary>
        public void GetSerList(HttpContext context, long contract_id)
        {
            var contract = new ctt_contract_dal().FindNoDeleteById(contract_id);

            if (contract != null)
            {
                var serviceList = new ctt_contract_service_dal().GetConSerList(contract.id);
                if (serviceList != null && serviceList.Count > 0)
                {
                    StringBuilder services = new StringBuilder();
                    var           oppBLL   = new OpportunityBLL();

                    var serList    = serviceList.Where(_ => _.object_type == 1).ToList();
                    var serBagList = serviceList.Where(_ => _.object_type == 2).ToList();
                    if (serList != null && serList.Count > 0)
                    {
                        foreach (var item in serList)
                        {
                            var name = oppBLL.ReturnServiceName(item.object_id);
                            services.Append("<option value='" + item.id + "'>" + name + "</option>");
                        }
                        if (serBagList != null && serBagList.Count > 0)
                        {
                            services.Append("<option>-------</option>");
                        }
                    }
                    if (serBagList != null && serBagList.Count > 0)
                    {
                        foreach (var item in serBagList)
                        {
                            var name = oppBLL.ReturnServiceName(item.object_id);
                            services.Append("<option value='" + item.id + "'>" + name + "</option>");
                        }
                    }



                    context.Response.Write(services);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// 判断当前合同是否有相关的服务/包,有的话返回,没有返回""
        /// </summary>
        /// <param name="context"></param>
        /// <param name="contract_id"></param>
        public void isHasService(HttpContext context, long contract_id)
        {
            var isHas    = "";
            var contract = new ctt_contract_dal().FindNoDeleteById(contract_id);

            if (contract != null)
            {
                var serviceList = new ctt_contract_service_dal().GetConSerList(contract.id);
                if (serviceList != null && serviceList.Count > 0)
                {
                    StringBuilder services = new StringBuilder("<option value='0'>     </option>");
                    var           oppBLL   = new OpportunityBLL();
                    foreach (var item in serviceList)
                    {
                        var name = oppBLL.ReturnServiceName(item.object_id);
                        services.Append("<option value='" + item.id + "'>" + name + "</option>");
                    }
                    context.Response.Write(services.ToString());
                    return;
                }
            }
            context.Response.Write(isHas);
        }
Пример #9
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>");
            }
        }
Пример #10
0
        /// <summary>
        /// 撤销定期服务审批
        /// </summary>
        /// <param name="user_id"></param>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ERROR_CODE Revoke_Recurring_Services(long user_id, string ids, out string re)
        {
            re = string.Empty;
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            StringBuilder                   returnvalue = new StringBuilder();
            crm_account_deduction           cad         = new crm_account_deduction();       //审批并提交
            ctt_contract_cost               ccc         = new ctt_contract_cost();           //成本
            ctt_contract                    cc          = new ctt_contract();                //合同
            ctt_contract_service_period     ccsp        = new ctt_contract_service_period(); //合同服务周期
            ctt_contract_service_adjust     ccsa        = new ctt_contract_service_adjust(); //合同服务调整
            ctt_contract_service_period_dal ccsp_dal    = new ctt_contract_service_period_dal();
            ctt_contract_service_adjust_dal ccsa_dal    = new ctt_contract_service_adjust_dal();

            if (!string.IsNullOrEmpty(ids))
            {
                var idList = ids.Split(',');
                foreach (var id in idList)
                {
                    var oldcad = cad = GetAccountDed(long.Parse(id));
                    if (cad.invoice_id != null)
                    {
                        var ci = new ctt_invoice_dal().FindNoDeleteById((long)cad.invoice_id);
                        if (ci.is_voided != 1)
                        {
                            returnvalue.Append(id + "条目已经生成发票(发票ID:" + cad.invoice_id + "),请先作废该发票\n");
                        }
                    }
                    else
                    {
                        cad.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                        cad.delete_user_id = user.id;
                        // 插入日志
                        var add1_log = new sys_oper_log()
                        {
                            user_cate           = "用户",
                            user_id             = (int)user.id,
                            name                = user.name,
                            phone               = user.mobile == null ? "" : user.mobile,
                            oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                            oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACCOUNT_DEDUCTION,
                            oper_object_id      = cad.id,// 操作对象id
                            oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                            oper_description    = cad_dal.CompareValue(oldcad, cad),
                            remark              = "删除审批并提交"
                        };                                       // 创建日志
                        new sys_oper_log_dal().Insert(add1_log); // 插入日志
                        if (!cad_dal.Update(cad))
                        {
                            return(ERROR_CODE.ERROR);
                        }
                        //类型为服务
                        if (cad.type_id == (int)ACCOUNT_DEDUCTION_TYPE.SERVICE)
                        {
                            var oldccsp = ccsp = ccsp_dal.FindSignleBySql <ctt_contract_service_period>($"select * from ctt_contract_service_period where contract_id={cad.contract_id} and delete_time=0");
                            ccsp.approve_and_post_date    = null;
                            ccsp.approve_and_post_user_id = null;
                            ccsp.period_adjusted_price    = ccsp.period_price * ccsp.quantity;
                            ccsp.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                            ccsp.update_user_id = user.id;
                            var add2_log = new sys_oper_log()
                            {
                                user_cate           = "用户",
                                user_id             = (int)user.id,
                                name                = user.name,
                                phone               = user.mobile == null ? "" : user.mobile,
                                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTRACT_SERVICE_PERIOD, //
                                oper_object_id      = ccsp.id,                                        // 操作对象id
                                oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                                oper_description    = cad_dal.CompareValue(oldccsp, ccsp),
                                remark              = "修改合同服务周期"
                            };                                       // 创建日志
                            new sys_oper_log_dal().Insert(add2_log); // 插入日志
                            if (!ccsp_dal.Update(ccsp))
                            {
                                return(ERROR_CODE.ERROR);
                            }
                        }
                        //类型为服务调整
                        if (cad.type_id == (int)ACCOUNT_DEDUCTION_TYPE.SERVICE_ADJUST)
                        {
                            var oldccsa = ccsa = ccsa_dal.FindSignleBySql <ctt_contract_service_adjust>($"select * from ctt_contract_service_adjust where contract_id={cad.contract_id} and delete_time=0");
                            cc = new ctt_contract_dal().FindSignleBySql <ctt_contract>($"select * from ctt_contract where id={cad.contract_id} and delete_time=0");
                            ccsa.approve_and_post_date        = null;
                            ccsa.approve_and_post_user_id     = null;
                            ccsa.adjust_prorated_price_change = (decimal)cc.setup_fee;
                            ccsa.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                            ccsa.update_user_id = user.id;
                            var add2_log = new sys_oper_log()
                            {
                                user_cate           = "用户",
                                user_id             = (int)user.id,
                                name                = user.name,
                                phone               = user.mobile == null ? "" : user.mobile,
                                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTRACT_SERVICE_ADJUST, //
                                oper_object_id      = ccsp.id,                                        // 操作对象id
                                oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                                oper_description    = cad_dal.CompareValue(oldccsa, ccsa),
                                remark              = "修改合同服务调整"
                            };                                       // 创建日志
                            new sys_oper_log_dal().Insert(add2_log); // 插入日志
                            if (ccsp_dal.Update(ccsp))
                            {
                            }
                        }
                        //类型为初始费用
                        if (cad.type_id == (int)ACCOUNT_DEDUCTION_TYPE.INITIAL_COST)
                        {
                            var oldcc = cc = new ctt_contract_dal().FindSignleBySql <ctt_contract>($"select * from ctt_contract where id={cad.contract_id} and delete_time=0");
                            cc.adjust_setup_fee = cc.setup_fee;
                            cc.setup_fee_approve_and_post_user_id = null;
                            cc.setup_fee_approve_and_post_date    = null;
                            cc.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                            cc.update_user_id = user.id;
                            var add2_log = new sys_oper_log()
                            {
                                user_cate           = "用户",
                                user_id             = (int)user.id,
                                name                = user.name,
                                phone               = user.mobile == null ? "" : user.mobile,
                                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTACTS,
                                oper_object_id      = cad.id,// 操作对象id
                                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                                oper_description    = cad_dal.CompareValue(oldcc, cc),
                                remark              = "修改合同初始费用"
                            };                                       // 创建日志
                            new sys_oper_log_dal().Insert(add2_log); // 插入日志
                            if (!new ctt_contract_dal().Update(cc))
                            {
                                return(ERROR_CODE.ERROR);
                            }
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(returnvalue.ToString()))
            {
                re = returnvalue.ToString();
                return(ERROR_CODE.EXIST);
            }
            return(ERROR_CODE.SUCCESS);
        }
Пример #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            thisUser = new sys_resource_dal().FindNoDeleteById(GetLoginUserId());
            var caDal  = new com_activity_dal();
            var stDal  = new sdk_task_dal();
            var ppDal  = new pro_project_dal();
            var accDal = new crm_account_dal();
            var ccDal  = new ctt_contract_dal();
            var id     = Request.QueryString["id"];

            if (!string.IsNullOrEmpty(id))
            {
                thisNote = caDal.FindNoDeleteById(long.Parse(id));
                if (thisNote != null)
                {
                    isAdd = false;

                    thisNoteAtt = new com_attachment_dal().GetAttListByOid(thisNote.id);

                    thisTicket = stDal.FindNoDeleteById(thisNote.object_id);
                    if (thisTicket != null)
                    {
                        object_id = thisTicket.id;
                    }
                    else
                    {
                        thisProject = ppDal.FindNoDeleteById(thisNote.object_id);
                        if (thisProject != null)
                        {
                            object_id   = thisProject.id;
                            thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                        }
                        else
                        {
                            thisContract = ccDal.FindNoDeleteById(thisNote.object_id);
                            if (thisContract != null)
                            {
                                object_id   = thisContract.id;
                                thisAccount = accDal.FindNoDeleteById(thisContract.account_id);
                            }
                        }
                    }
                }
            }

            var ticketId = Request.QueryString["ticket_id"];

            if (!string.IsNullOrEmpty(ticketId))
            {
                thisTicket = stDal.FindNoDeleteById(long.Parse(ticketId));
            }
            if (thisTicket != null)
            {
                object_id = thisTicket.id;
                if (thisTicket.type_id == (int)DicEnum.TASK_TYPE.PROJECT_PHASE)
                {
                    // isPhase = true;
                }
                if (thisTicket.contact_id != null)
                {
                    thisContact = new crm_contact_dal().FindNoDeleteById((long)thisTicket.contact_id);
                }
                thisAccount    = accDal.FindNoDeleteById(thisTicket.account_id);
                ticket_creator = new sys_resource_dal().FindNoDeleteById(thisTicket.create_user_id);
                if (!IsPostBack)
                {
                    //status_id.SelectedValue = thisTicket.status_id.ToString();
                }

                if (thisTicket.project_id != null)
                {
                    thisProject = ppDal.FindNoDeleteById((long)thisTicket.project_id);
                    if (thisProject != null && thisAccount != null)
                    {
                        thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                    }
                }
            }
            if (thisAccount == null)
            {
                Response.End();
            }
            else
            {
                if (thisAccount.resource_id != null)
                {
                    thisAccManger = new sys_resource_dal().FindNoDeleteById((long)thisAccount.resource_id);
                }
            }

            if (!IsPostBack)
            {
                publish_type_id.DataTextField  = "name";
                publish_type_id.DataValueField = "id";
                var pushList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.NOTE_PUBLISH_TYPE);
                if (pushList != null && pushList.Count > 0)
                {
                    pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TICKET_NOTE).ToString()).ToList();
                }
                publish_type_id.DataSource = pushList;
                publish_type_id.DataBind();

                status_id.DataTextField  = "show";
                status_id.DataValueField = "val";
                status_id.DataSource     = dic.FirstOrDefault(_ => _.Key == "ticket_status").Value;
                status_id.DataBind();
                if (thisTicket != null)
                {
                    status_id.SelectedValue = thisTicket.status_id.ToString();
                }

                action_type_id.DataTextField  = "name";
                action_type_id.DataValueField = "id";
                var actList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.ACTION_TYPE);
                actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                action_type_id.DataSource = actList;
                action_type_id.DataBind();


                if (thisNote != null)
                {
                    if (!IsPostBack)
                    {
                        if (thisNote.publish_type_id != null)
                        {
                            publish_type_id.SelectedValue = thisNote.publish_type_id.ToString();
                        }
                        action_type_id.SelectedValue = thisNote.action_type_id.ToString();
                    }
                }
                //else
                //{
                //    if (isContract)
                //    {
                //        publish_type_id.SelectedValue = ((int)DicEnum.NOTE_PUBLISH_TYPE.CONTRACT_INTERNA_USER).ToString();
                //    }
                //}

                var tempList = new sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.NONE);
                notify_id.DataTextField  = "name";
                notify_id.DataValueField = "id";
                notify_id.DataSource     = tempList;
                notify_id.DataBind();
            }
        }
Пример #12
0
        /// <summary>
        /// 新增附件
        /// </summary>
        /// <param name="objType">对象类型</param>
        /// <param name="objId">对象id</param>
        /// <param name="typeId">附件类型</param>
        /// <param name="title">附件名</param>
        /// <param name="attLink">附件内容</param>
        /// <param name="fileName">上传的文件名</param>
        /// <param name="fileSaveName">文件保存服务器的名称</param>
        /// <param name="contentType">文件类型</param>
        /// <param name="size">文件大小</param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool AddAttachment(int objType, long objId, int typeId, string title, string attLink, string fileName, string fileSaveName, string contentType, int size, long userId, string pubTypeId = "")
        {
            com_attachment att = new com_attachment();


            att.object_type_id = objType;
            att.object_id      = objId;

            // 备注和附件的下级备注和附件不能再添加附件
            if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES)
            {
                var note = new com_activity_dal().FindById(objId);
                if (note.object_type_id == (int)DicEnum.OBJECT_TYPE.NOTES)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES;
                    att.object_id      = note.object_id;
                }
                else if (note.object_type_id == (int)DicEnum.OBJECT_TYPE.ATTACHMENT)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT;
                    att.object_id      = note.object_id;
                }
            }
            else if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT)
            {
                var attachment = dal.FindById(objId);
                if (attachment.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES;
                    att.object_id      = attachment.object_id;
                }
                else if (attachment.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT;
                    att.object_id      = attachment.object_id;
                }
            }
            else if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR)
            {
                var labour = new sdk_work_entry_dal().FindById(objId);
                if (labour.parent_id != null)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR;
                    att.object_id      = (long)labour.parent_id;
                }
                else if (labour.parent_attachment_id != null)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT;
                    att.object_id      = (long)labour.parent_attachment_id;
                }
                else if (labour.parent_note_id != null)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES;
                    att.object_id      = (long)labour.parent_note_id;
                }
            }

            if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT)
            {
                var attachment = dal.FindById(att.object_id);
                att.account_id = attachment.account_id;
                att.parent_id  = attachment.id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES)
            {
                var note = new com_activity_dal().FindById(att.object_id);
                att.account_id = note.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.OPPORTUNITY)
            {
                var opp = new crm_opportunity_dal().FindById(att.object_id);
                att.account_id = opp.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.SALES_ORDER)
            {
                var so  = new crm_sales_order_dal().FindById(att.object_id);
                var opp = new crm_opportunity_dal().FindById(so.opportunity_id);
                att.account_id = opp.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.CONTRACT)
            {
                var contract = new ctt_contract_dal().FindById(att.object_id);
                att.account_id = contract.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.COMPANY)
            {
                att.account_id = att.object_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.PROJECT)
            {
                var project = new pro_project_dal().FindNoDeleteById(att.object_id);
                att.account_id = project.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.EXPENSE_REPORT)
            {
                // 从报表添加附件 - 默认使用声联(oid=0) 的客户
                var defaultAccount = new CompanyBLL().GetDefaultAccount();
                att.account_id = defaultAccount.id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.TASK)
            {
                var task = new sdk_task_dal().FindNoDeleteById(att.object_id);
                if (task != null)
                {
                    att.account_id = task.account_id;
                    #region 更新客户最后活动时间
                    crm_account thisAccount = new CompanyBLL().GetCompany(task.account_id);
                    if (thisAccount != null)
                    {
                        thisAccount.last_activity_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); new CompanyBLL().EditAccount(thisAccount, userId);
                    }
                    #endregion
                }
                if (!string.IsNullOrEmpty(pubTypeId))
                {
                    att.publish_type_id = int.Parse(pubTypeId);
                }
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR)
            {
                var labour = new sdk_work_entry_dal().FindNoDeleteById(att.object_id);
                if (labour == null)
                {
                    return(false);
                }
                var ticket = new sdk_task_dal().FindNoDeleteById(labour.task_id);
                if (ticket == null)
                {
                    return(false);
                }
                att.account_id = ticket.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.KNOWLEDGE)
            {
                var thisArt = new sdk_kb_article_dal().FindNoDeleteById(att.object_id);
                if (thisArt == null)
                {
                    return(false);
                }
                att.account_id = thisArt.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.RESOURCE)
            {
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.CONFIGITEM)
            {
                crm_installed_product insPro = new crm_installed_product_dal().FindNoDeleteById(att.object_id);
                if (insPro == null)
                {
                    return(false);
                }
                att.account_id = insPro.account_id;
            }
            else
            {
                return(false);
            }

            att.id             = dal.GetNextIdCom();
            att.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
            att.create_user_id = userId;
            att.update_time    = att.create_time;
            att.update_user_id = userId;
            att.title          = title;
            att.type_id        = typeId;
            if (typeId == (int)DicEnum.ATTACHMENT_TYPE.FILE_LINK ||
                typeId == (int)DicEnum.ATTACHMENT_TYPE.FOLDER_LINK)
            {
                att.uncpath  = attLink;
                att.filename = @"file://" + attLink;
            }
            else if (typeId == (int)DicEnum.ATTACHMENT_TYPE.URL)
            {
                if (attLink.IndexOf(@"http://") == 0)
                {
                    attLink      = attLink.Remove(0, 7);
                    att.urlpath  = attLink;
                    att.filename = @"http://" + attLink;
                }
                else if (attLink.IndexOf(@"https://") == 0)
                {
                    attLink      = attLink.Remove(0, 8);
                    att.urlpath  = attLink;
                    att.filename = @"https://" + attLink;
                }
                else
                {
                    att.urlpath  = attLink;
                    att.filename = @"http://" + attLink;
                }
            }
            else if (typeId == (int)DicEnum.ATTACHMENT_TYPE.ATTACHMENT)
            {
                att.href         = fileSaveName;
                att.filename     = fileName;
                att.sizeinbyte   = size;
                att.content_type = contentType;
            }
            else
            {
                return(false);
            }

            dal.Insert(att);
            OperLogBLL.OperLogAdd <com_attachment>(att, att.id, userId, DicEnum.OPER_LOG_OBJ_CATE.ATTACHMENT, "新增附件");
            return(true);
        }
Пример #13
0
        /// <summary>
        /// 取消配送
        /// </summary>
        /// <param name="costPdtIds">成本产品id</param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public string PurchaseUnShip(string costPdtIds, long userId)
        {
            ctt_contract_cost_product_dal cstPdtDal = new ctt_contract_cost_product_dal();
            var pdtList = cstPdtDal.FindListBySql <ctt_contract_cost_product>($"select * from ctt_contract_cost_product where id in({costPdtIds})");

            if (pdtList == null || pdtList.Count == 0)
            {
                return("");
            }

            ctt_contract_cost_dal        costDal     = new ctt_contract_cost_dal();
            ivt_transfer_dal             tsfDal      = new ivt_transfer_dal();
            ctt_contract_dal             cttDal      = new ctt_contract_dal();
            pro_project_dal              proDal      = new pro_project_dal();
            sdk_task_dal                 tskDal      = new sdk_task_dal();
            ivt_warehouse_product_sn_dal lctPdtSnDal = new ivt_warehouse_product_sn_dal();
            ivt_transfer_sn_dal          tsfSnDal    = new ivt_transfer_sn_dal();

            foreach (var pdt in pdtList)
            {
                // 修改成本产品状态
                var pdtOld = cstPdtDal.FindById(pdt.id);
                pdt.status_id      = (int)DicEnum.CONTRACT_COST_PRODUCT_STATUS.PENDING_DISTRIBUTION;
                pdt.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                pdt.shipping_time  = null;
                pdt.update_user_id = userId;
                cstPdtDal.Update(pdt);
                OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ctt_contract_cost_product>(pdtOld, pdt), pdt.id, userId, DicEnum.OPER_LOG_OBJ_CATE.CTT_CONTRACT_COST_PRODUCT, "成本产品配送");

                // 修改成本状态
                var cost = costDal.FindById(pdt.contract_cost_id);
                if (cost.status_id == (int)DicEnum.COST_STATUS.ALREADY_DELIVERED)
                {
                    var costOld = costDal.FindById(pdt.contract_cost_id);
                    cost.status_id      = (int)DicEnum.COST_STATUS.PENDING_DELIVERY;
                    cost.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                    cost.update_user_id = userId;
                    costDal.Update(cost);
                    OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ctt_contract_cost>(costOld, cost), cost.id, userId, DicEnum.OPER_LOG_OBJ_CATE.CONTRACT_COST, "取消配送修改成本状态");
                }

                // 新建库存转移信息
                ivt_transfer tsf = new ivt_transfer();
                tsf.id             = tsfDal.GetNextIdCom();
                tsf.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                tsf.update_user_id = userId;
                tsf.create_time    = tsf.update_time;
                tsf.create_user_id = userId;
                tsf.type_id        = (int)DicEnum.INVENTORY_TRANSFER_TYPE.PROJECT;
                tsf.product_id     = (long)cost.product_id;
                tsf.quantity       = 0 - pdt.quantity;
                if (cost.contract_id != null)
                {
                    tsf.to_account_id = cttDal.FindById((long)cost.contract_id).account_id;
                }
                else if (cost.project_id != null)
                {
                    tsf.to_account_id = proDal.FindById((long)cost.project_id).account_id;
                }
                else if (cost.task_id != null)
                {
                    tsf.to_account_id = tskDal.FindById((long)cost.task_id).account_id;
                }
                tsf.to_contract_id    = cost.contract_id;
                tsf.to_project_id     = cost.project_id;
                tsf.to_task_id        = cost.task_id;
                tsf.from_warehouse_id = (long)pdt.warehouse_id;
                tsfDal.Insert(tsf);
                OperLogBLL.OperLogAdd <ivt_transfer>(tsf, tsf.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_TRANSFER, "取消配送新建库存转移");


                // 保存库存数修改
                var lctPdt = dal.FindSignleBySql <ivt_warehouse_product>($"select * from ivt_warehouse_product where product_id={cost.product_id} and warehouse_id={(long)pdt.warehouse_id} and delete_time=0");
                if (lctPdt != null)
                {
                    var lctPdtOld = dal.FindById(lctPdt.id);
                    lctPdt.quantity       = lctPdt.quantity + pdt.quantity;
                    lctPdt.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                    lctPdt.update_user_id = userId;
                    dal.Update(lctPdt);
                    OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ivt_warehouse_product>(lctPdtOld, lctPdt), lctPdt.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM, "修改库存产品库存数");

                    var sns = costDal.FindListBySql <string>($"select sn from ctt_contract_cost_product_sn where contract_cost_product_id={pdt.id} and delete_time=0");
                    if (sns == null || sns.Count == 0)
                    {
                        continue;
                    }

                    foreach (var sn in sns)
                    {
                        ivt_warehouse_product_sn lctPdtSn = new ivt_warehouse_product_sn();
                        lctPdtSn.id                   = lctPdtSnDal.GetNextIdCom();
                        lctPdtSn.create_time          = Tools.Date.DateHelper.ToUniversalTimeStamp();
                        lctPdtSn.create_user_id       = userId;
                        lctPdtSn.update_time          = lctPdtSn.create_time;
                        lctPdtSn.update_user_id       = userId;
                        lctPdtSn.warehouse_product_id = lctPdt.id;
                        lctPdtSn.sn                   = sn;
                        lctPdtSnDal.Insert(lctPdtSn);
                        OperLogBLL.OperLogAdd <ivt_warehouse_product_sn>(lctPdtSn, lctPdtSn.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_SN, "取消配送产品新增库存产品串号");

                        ivt_transfer_sn tsfSn = new ivt_transfer_sn();
                        tsfSn.id             = tsfSnDal.GetNextIdCom();
                        tsfSn.sn             = sn;
                        tsfSn.transfer_id    = tsf.id;
                        tsfSn.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                        tsfSn.create_user_id = userId;
                        tsfSn.update_time    = tsfSn.create_time;
                        tsfSn.update_user_id = userId;
                        tsfSnDal.Insert(tsfSn);
                        OperLogBLL.OperLogAdd <ivt_transfer_sn>(tsfSn, tsfSn.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_TRANSFER_SN, "取消配送产品新增转移产品串号");
                    }
                }
            }

            return("");
        }
Пример #14
0
        /// <summary>
        /// 配送
        /// </summary>
        /// <param name="costPdtIds">成本产品id</param>
        /// <param name="isEditSaleOrder">是否修改销售订单状态</param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public string PurchaseShip(string costPdtIds, bool isEditSaleOrder, long userId)
        {
            ctt_contract_cost_product_dal cstPdtDal = new ctt_contract_cost_product_dal();
            var pdtList = cstPdtDal.FindListBySql <ctt_contract_cost_product>($"select * from ctt_contract_cost_product where id in({costPdtIds})");

            if (pdtList == null || pdtList.Count == 0)
            {
                return("");
            }

            foreach (var pdt in pdtList)
            {
                if (pdt.status_id != (int)DicEnum.CONTRACT_COST_PRODUCT_STATUS.PENDING_DISTRIBUTION)
                {
                    return("状态为“待配送”的成本产品才能配送");
                }
            }

            ctt_contract_cost_dal        costDal     = new ctt_contract_cost_dal();
            ivt_transfer_dal             tsfDal      = new ivt_transfer_dal();
            ctt_contract_dal             cttDal      = new ctt_contract_dal();
            pro_project_dal              proDal      = new pro_project_dal();
            sdk_task_dal                 tskDal      = new sdk_task_dal();
            ivt_warehouse_product_sn_dal lctPdtSnDal = new ivt_warehouse_product_sn_dal();
            ivt_transfer_sn_dal          tsfSnDal    = new ivt_transfer_sn_dal();

            foreach (var pdt in pdtList)
            {
                var pdtOld = cstPdtDal.FindById(pdt.id);
                pdt.status_id      = (int)DicEnum.CONTRACT_COST_PRODUCT_STATUS.DISTRIBUTION;
                pdt.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                pdt.shipping_time  = pdt.update_time;
                pdt.update_user_id = userId;
                cstPdtDal.Update(pdt);
                OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ctt_contract_cost_product>(pdtOld, pdt), pdt.id, userId, DicEnum.OPER_LOG_OBJ_CATE.CTT_CONTRACT_COST_PRODUCT, "成本产品配送");

                var cost = costDal.FindById(pdt.contract_cost_id);
                var cnt  = dal.FindSignleBySql <int>($"select count(0) from ctt_contract_cost_product where contract_cost_id={pdt.contract_cost_id} and status_id<>{(int)DicEnum.CONTRACT_COST_PRODUCT_STATUS.DISTRIBUTION} and delete_time=0");
                if (cnt == 0)   // 产品全部已配送,修改成本状态
                {
                    var costOld = costDal.FindById(pdt.contract_cost_id);
                    cost.status_id      = (int)DicEnum.COST_STATUS.ALREADY_DELIVERED;
                    cost.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                    cost.update_user_id = userId;
                    costDal.Update(cost);
                    OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ctt_contract_cost>(costOld, cost), cost.id, userId, DicEnum.OPER_LOG_OBJ_CATE.CONTRACT_COST, "修改成本状态已配送");
                }

                ivt_transfer transfer = new ivt_transfer();
                transfer.id                = tsfDal.GetNextIdCom();
                transfer.create_time       = Tools.Date.DateHelper.ToUniversalTimeStamp();
                transfer.create_user_id    = userId;
                transfer.update_time       = transfer.create_time;
                transfer.update_user_id    = userId;
                transfer.product_id        = (long)cost.product_id;
                transfer.type_id           = (int)DicEnum.INVENTORY_TRANSFER_TYPE.PROJECT;
                transfer.from_warehouse_id = (long)pdt.warehouse_id;
                transfer.quantity          = pdt.quantity;
                if (cost.contract_id != null)
                {
                    transfer.to_account_id = cttDal.FindById((long)cost.contract_id).account_id;
                }
                else if (cost.project_id != null)
                {
                    transfer.to_account_id = proDal.FindById((long)cost.project_id).account_id;
                }
                else if (cost.task_id != null)
                {
                    transfer.to_account_id = tskDal.FindById((long)cost.task_id).account_id;
                }
                transfer.to_contract_id = cost.contract_id;
                transfer.to_project_id  = cost.project_id;
                transfer.to_task_id     = cost.task_id;
                tsfDal.Insert(transfer);
                OperLogBLL.OperLogAdd <ivt_transfer>(transfer, transfer.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_TRANSFER, "产品配送转移库存");

                // 保存库存数修改
                var lctPdt = dal.FindSignleBySql <ivt_warehouse_product>($"select * from ivt_warehouse_product where product_id={cost.product_id} and warehouse_id={(long)pdt.warehouse_id} and delete_time=0");
                if (lctPdt != null)
                {
                    var lctPdtOld = dal.FindById(lctPdt.id);
                    lctPdt.quantity       = lctPdt.quantity - pdt.quantity;
                    lctPdt.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                    lctPdt.update_user_id = userId;
                    dal.Update(lctPdt);
                    OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ivt_warehouse_product>(lctPdtOld, lctPdt), lctPdt.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM, "修改库存产品库存数");

                    var sns = costDal.FindListBySql <string>($"select sn from ctt_contract_cost_product_sn where contract_cost_product_id={pdt.id} and delete_time=0");
                    if (sns == null || sns.Count == 0)
                    {
                        continue;
                    }

                    foreach (var sn in sns)
                    {
                        var lctPdtSn = lctPdtSnDal.FindSignleBySql <ivt_warehouse_product_sn>($"select * from ivt_warehouse_product_sn where sn='{sn}' and warehouse_product_id={lctPdt.id}");
                        lctPdtSn.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                        lctPdtSn.delete_user_id = userId;
                        lctPdtSnDal.Update(lctPdtSn);
                        OperLogBLL.OperLogDelete <ivt_warehouse_product_sn>(lctPdtSn, lctPdtSn.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_SN, "配送产品删除库存产品串号");

                        ivt_transfer_sn tsfSn = new ivt_transfer_sn();
                        tsfSn.id             = tsfSnDal.GetNextIdCom();
                        tsfSn.sn             = sn;
                        tsfSn.transfer_id    = transfer.id;
                        tsfSn.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
                        tsfSn.create_user_id = userId;
                        tsfSn.update_time    = tsfSn.create_time;
                        tsfSn.update_user_id = userId;
                        tsfSnDal.Insert(tsfSn);
                        OperLogBLL.OperLogAdd <ivt_transfer_sn>(tsfSn, tsfSn.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_TRANSFER_SN, "配送产品新增转移产品串号");
                    }
                }
            }

            return("");
        }
Пример #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                thisUser = new sys_resource_dal().FindNoDeleteById(GetLoginUserId());
                var caDal  = new com_activity_dal();
                var stDal  = new sdk_task_dal();
                var ppDal  = new pro_project_dal();
                var accDal = new crm_account_dal();
                var ccDal  = new ctt_contract_dal();
                var id     = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    thisNote = caDal.FindNoDeleteById(long.Parse(id));
                    if (thisNote != null)
                    {
                        isAdd = false;

                        thisNoteAtt = new com_attachment_dal().GetAttListByOid(thisNote.id);

                        thisTask = stDal.FindNoDeleteById(thisNote.object_id);
                        if (thisTask != null)
                        {
                            object_id = thisTask.id;
                            if (thisTask.type_id == (int)DicEnum.TASK_TYPE.SERVICE_DESK_TICKET)
                            {
                                isTicket   = true;
                                thisTask   = null;
                                thisTicket = stDal.FindNoDeleteById(thisNote.object_id);
                            }
                        }
                        else
                        {
                            thisProject = ppDal.FindNoDeleteById(thisNote.object_id);
                            if (thisProject != null)
                            {
                                isProject   = true;
                                object_id   = thisProject.id;
                                thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                            }
                            else
                            {
                                thisContract = ccDal.FindNoDeleteById(thisNote.object_id);
                                if (thisContract != null)
                                {
                                    isContract  = true;
                                    object_id   = thisContract.id;
                                    thisAccount = accDal.FindNoDeleteById(thisContract.account_id);
                                }
                            }
                        }
                    }
                }
                var taskId      = Request.QueryString["task_id"];
                var project_id  = Request.QueryString["project_id"];
                var contract_id = Request.QueryString["contract_id"];
                var ticket_id   = Request.QueryString["ticket_id"];
                var call_id     = Request.QueryString["call_id"];
                if (!string.IsNullOrEmpty(taskId))
                {
                    thisTask = stDal.FindNoDeleteById(long.Parse(taskId));
                }
                else if (!string.IsNullOrEmpty(project_id))
                {
                    thisProject = ppDal.FindNoDeleteById(long.Parse(project_id));
                    if (thisProject != null)
                    {
                        isProject   = true;
                        object_id   = thisProject.id;
                        thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                    }
                }
                else if (!string.IsNullOrEmpty(contract_id))
                {
                    thisContract = ccDal.FindNoDeleteById(long.Parse(contract_id));
                    if (thisContract != null)
                    {
                        object_id   = thisContract.id;
                        thisAccount = accDal.FindNoDeleteById(thisContract.account_id);
                        isContract  = true;
                    }
                }
                else if (!string.IsNullOrEmpty(ticket_id))
                {
                    thisTicket = stDal.FindNoDeleteById(long.Parse(ticket_id));
                }
                else if (!string.IsNullOrEmpty(call_id))
                {
                    thisCall = new sdk_service_call_dal().FindNoDeleteById(long.Parse(call_id));
                    if (thisCall != null)
                    {
                        isCall         = true;
                        thisAccount    = new CompanyBLL().GetCompany(thisCall.account_id);
                        callTicketList = stDal.GetTciketByCall(thisCall.id);
                        if (callTicketList != null && callTicketList.Count > 0)
                        {
                            thisTask = callTicketList[0];
                            if (callTicketList.Any(_ => _.id != thisTask.id && _.status_id != thisTask.status_id))
                            {
                                isMantStatus = true;
                            }
                            if (callTicketList.Any(_ => _.id != thisTask.id && _.account_id != thisTask.account_id))
                            {
                                isManyAccount = true;
                            }
                            if (callTicketList.Any(_ => _.id != thisTask.id && _.title != thisTask.title))
                            {
                                isManyTitle = true;
                            }
                        }
                        else
                        {
                            Response.Write("<script>alert('服务预定下暂无工单!');window.close();</script>");
                            return;
                        }
                    }
                }


                if (thisTask != null)
                {
                    thisAccount = accDal.FindNoDeleteById(thisTask.account_id);
                    object_id   = thisTask.id;
                    if (thisTask.type_id == (int)DicEnum.TASK_TYPE.PROJECT_PHASE)
                    {
                        isPhase = true;
                    }
                    task_creator = new sys_resource_dal().FindNoDeleteById(thisTask.create_user_id);
                    if (thisTask.project_id != null)
                    {
                        thisProject = ppDal.FindNoDeleteById((long)thisTask.project_id);
                        if (thisProject != null)
                        {
                            thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                        }
                    }
                }
                if (thisTicket != null)
                {
                    isTicket     = true;
                    object_id    = thisTicket.id;
                    task_creator = new sys_resource_dal().FindNoDeleteById(thisTicket.create_user_id);
                    thisAccount  = accDal.FindNoDeleteById(thisTicket.account_id);
                    if (thisTicket.contact_id != null)
                    {
                        thisContact = new crm_contact_dal().FindNoDeleteById((long)thisTicket.contact_id);
                    }
                }
                if (thisAccount == null)
                {
                    Response.End();
                }
                else
                {
                    if (thisAccount.resource_id != null)
                    {
                        thisAccManger = new sys_resource_dal().FindNoDeleteById((long)thisAccount.resource_id);
                    }
                }
                if (!IsPostBack)
                {
                    publish_type_id.DataTextField  = "name";
                    publish_type_id.DataValueField = "id";
                    var pushList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.NOTE_PUBLISH_TYPE);
                    if (pushList != null && pushList.Count > 0)
                    {
                        if (isProject)
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.PROJECT_NOTE).ToString()).ToList();
                        }
                        else if (isContract)
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.CONTRACT_NOTE).ToString()).ToList();
                        }
                        else if (isTicket)
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                        else
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                    }
                    publish_type_id.DataSource = pushList;
                    publish_type_id.DataBind();

                    status_id.DataTextField  = "show";
                    status_id.DataValueField = "val";
                    var statusList = dic.FirstOrDefault(_ => _.Key == "ticket_status").Value as List <DictionaryEntryDto>;
                    if (isMantStatus)
                    {
                        statusList.Add(new DictionaryEntryDto()
                        {
                            val = "0", show = "多个值,保持不变"
                        });
                    }
                    status_id.DataSource = statusList;
                    status_id.DataBind();
                    if (isMantStatus)
                    {
                        status_id.SelectedValue = "0";
                    }
                    else if (thisTask != null)
                    {
                        status_id.SelectedValue = thisTask.status_id.ToString();
                    }
                    else if (thisTicket != null)
                    {
                        status_id.SelectedValue = thisTicket.status_id.ToString();
                    }
                    action_type_id.DataTextField  = "name";
                    action_type_id.DataValueField = "id";
                    var actList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.ACTION_TYPE);
                    if (actList != null && actList.Count > 0)
                    {
                        if (isProject)
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.PROJECT_NOTE).ToString()).ToList();
                        }
                        else if (isContract)
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.CONTRACT_NOTE).ToString()).ToList();
                        }
                        else if (isTicket)
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                        else
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                    }
                    action_type_id.DataSource = actList;
                    action_type_id.DataBind();
                    if (thisNote != null)
                    {
                        if (!IsPostBack)
                        {
                            if (thisNote.publish_type_id != null)
                            {
                                publish_type_id.SelectedValue = thisNote.publish_type_id.ToString();
                            }
                            action_type_id.SelectedValue = thisNote.action_type_id.ToString();
                            isAnnounce.Checked           = thisNote.announce == 1;
                        }
                    }
                    else
                    {
                        if (isContract)
                        {
                            publish_type_id.SelectedValue = ((int)DicEnum.NOTE_PUBLISH_TYPE.CONTRACT_INTERNA_USER).ToString();
                        }
                    }

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

                if (isProject)
                {
                    tmplList = new FormTemplateBLL().GetTmplByType((int)DicEnum.FORM_TMPL_TYPE.PROJECT_NOTE, LoginUserId);
                }
                else if (isTicket && thisTicket != null)
                {
                    tmplList = new FormTemplateBLL().GetTmplByType((int)DicEnum.FORM_TMPL_TYPE.TICKET_NOTE, LoginUserId);
                }
                else if (thisTask != null)
                {
                    tmplList = new FormTemplateBLL().GetTmplByType((int)DicEnum.FORM_TMPL_TYPE.TASK_NOTE, LoginUserId);
                }
            }
            catch (Exception msg)
            {
                Response.Write(msg);
                Response.End();
            }
        }