Esempio n. 1
0
        /// <summary>
        /// 获取到下拉框中客户和父客户的联系人
        /// </summary>
        private void GetParAndAccSelect(HttpContext context, long account_id)
        {
            StringBuilder conHtml = new StringBuilder();

            var account = new crm_account_dal().FindNoDeleteById(account_id);

            if (account != null)
            {
                var conList = new crm_contact_dal().GetContactByAccountId(account.id);
                if (conList != null && conList.Count > 0)
                {
                    foreach (var con in conList)
                    {
                        conHtml.Append($"<option value='{con.id}'>{con.name}</option>");
                    }
                }
                if (account.parent_id != null)
                {
                    var parConList = new crm_contact_dal().GetContactByAccountId((long)account.parent_id);
                    if (parConList != null && parConList.Count > 0)
                    {
                        conHtml.Append("<option value=''>-----</option>");
                        foreach (var con in conList)
                        {
                            conHtml.Append($"<option value='{con.id}'>{con.name}</option>");
                        }
                    }
                }
            }
            context.Response.Write(conHtml.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// 删除前校验
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE Delete_Validate(long id, long user_id, out int n)
        {
            n = 0;
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var data = _dal.FindById(id);

            if (data == null)
            {
                return(ERROR_CODE.ERROR);
            }
            if (data.is_system > 0)
            {
                return(ERROR_CODE.SYSTEM);
            }
            var mar = new crm_account_dal().FindListBySql($"select * from crm_account where classification_id={id} and delete_time=0");

            if (mar.Count > 0)
            {
                n = mar.Count;
                return(ERROR_CODE.ACCOUNT_TYPE_USED);
            }
            data.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            data.delete_user_id = user_id;
            if (!_dal.Update(data))
            {
                return(ERROR_CODE.ERROR);
            }
            return(ERROR_CODE.SUCCESS);
        }
Esempio n. 3
0
        /// <summary>
        /// 获取到客户和父客户的联系人
        /// </summary>
        private void GetConAccAndPar(HttpContext context, long account_id)
        {
            StringBuilder conHtml = new StringBuilder();

            var account = new crm_account_dal().FindNoDeleteById(account_id);

            if (account != null)
            {
                var conList = new crm_contact_dal().GetContactByAccountId(account.id);
                if (conList != null && conList.Count > 0)
                {
                    foreach (var con in conList)
                    {
                        conHtml.Append("<tr><td><input type='checkbox' value='" + con.id + "' class='checkCon' /></td><td>" + con.name + "</td><td><a href='mailto:" + con.email + "'>" + con.email + "</a></td></tr>");
                    }
                }
                if (account.parent_id != null)
                {
                    var parConList = new crm_contact_dal().GetContactByAccountId((long)account.parent_id);
                    if (parConList != null && parConList.Count > 0)
                    {
                        conHtml.Append("<tr><td colspan='3'>父客户联系人</td></tr>");
                        foreach (var con in conList)
                        {
                            conHtml.Append("<tr><td><input type='checkbox' value='" + con.id + "' class='checkCon' /></td><td>" + con.name + "</td><td><a href='mailto:" + con.email + "'>" + con.email + "</a></td></tr>");
                        }
                    }
                }
            }
            context.Response.Write(conHtml.ToString());
        }
Esempio n. 4
0
        /// <summary>
        /// 通过id删除
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE Delete(long id, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var data = _dal.FindById(id);

            if (data == null)
            {
                return(ERROR_CODE.ERROR);
            }
            if (data.is_system > 0)
            {
                return(ERROR_CODE.SYSTEM);
            }
            var mar = new crm_account_dal().FindListBySql($"select * from crm_account where classification_id={id} and delete_time=0");

            if (mar.Count > 0)
            {
                foreach (var acc in mar)
                {
                    acc.classification_id = null;
                    acc.update_time       = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    acc.update_user_id    = user_id;
                    if (!new crm_account_dal().Update(acc))
                    {
                        return(ERROR_CODE.ERROR);
                    }
                }
            }
            data.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            data.delete_user_id = user_id;
            if (!_dal.Update(data))
            {
                return(ERROR_CODE.ERROR);
            }
            var add_log = new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = (int)user.id,
                name                = "",
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACCOUNTCLASS, //
                oper_object_id      = data.id,                             // 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                oper_description    = _dal.AddValue(data),
                remark              = "删除客户类别信息"
            };                                      // 创建日志

            new sys_oper_log_dal().Insert(add_log); // 插入日志
            return(ERROR_CODE.SUCCESS);
        }
Esempio n. 5
0
        /// <summary>
        /// 根据员工和相关条件获取相对应的客户
        /// </summary>
        private void GetAccByRes(HttpContext context, long rId, string showType, bool isShowComp)
        {
            var list = new crm_account_dal().GetAccByRes(rId, showType, isShowComp);

            if (list != null && list.Count > 0)
            {
                // var accDic = list.GroupBy(_ => _.id).ToDictionary(_ => _.Key, _ => _.FirstOrDefault(f=>!string.IsNullOrEmpty(f.name)).name);
                context.Response.Write(new Tools.Serialize().SerializeJson(list));
            }
        }
Esempio n. 6
0
        void GetAccountByIds(HttpContext context)
        {
            var ids = context.Request.QueryString["ids"];

            if (!string.IsNullOrEmpty(ids))
            {
                List <crm_account> accList = new crm_account_dal().GetCompanyByIds(ids);
                if (accList != null && accList.Count > 0)
                {
                    WriteResponseJson(accList);
                }
            }
        }
Esempio n. 7
0
        private void GetVendorsByProductId(HttpContext context, long product_id)
        {
            var vendorList = new crm_account_dal().FindListBySql <crm_account>($"SELECT * from crm_account where id in(  select vendor_account_id from ivt_product_vendor where  product_id = {product_id} )");

            if (vendorList != null && vendorList.Count > 0)
            {
                StringBuilder vendors = new StringBuilder();
                foreach (var vendor in vendorList)
                {
                    vendors.Append("<option value='" + vendor.id + "'>" + vendor.name + "</option>");
                }
                context.Response.Write(vendors);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 新增合同时添加服务包
        /// </summary>
        /// <param name="context"></param>
        /// <param name="id"></param>
        public void AddServiceBundle(HttpContext context, long id)
        {
            var           serBun          = new ivt_service_bundle_dal().FindById(id);
            string        txt             = "";
            decimal       pricePerPeriod  = 0;
            int           monthsPerPeriod = 1;
            List <object> result          = new List <object>();

            if (serBun == null)
            {
                result.Add(txt);
                result.Add(pricePerPeriod);

                context.Response.Write(new Tools.Serialize().SerializeJson(result));
                return;
            }

            // 获取供应商名称
            string vendorName = "";

            if (serBun.vendor_account_id != null)
            {
                var vendorDal  = new ivt_product_vendor_dal();
                var accountDal = new crm_account_dal();
                var vendor     = vendorDal.FindById((long)serBun.vendor_account_id);
                if (vendor.vendor_account_id != null)
                {
                    vendorName = accountDal.FindById((long)vendor.vendor_account_id).name;
                }
            }

            // 周期
            string period = "";

            if (serBun.period_type_id != null)
            {
                period = new GeneralBLL().GetGeneralName((int)serBun.period_type_id);
                if (serBun.unit_price == null)
                {
                    pricePerPeriod = 0;
                }
                else
                {
                    pricePerPeriod = (decimal)serBun.unit_price;
                }

                if (serBun.period_type_id == (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.QUARTER)
                {
                    monthsPerPeriod = 3;
                }
                if (serBun.period_type_id == (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.HALFYEAR)
                {
                    monthsPerPeriod = 6;
                }
                if (serBun.period_type_id == (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.YEAR)
                {
                    monthsPerPeriod = 12;
                }
            }

            string unitCost = "";

            if (serBun.unit_cost != null)
            {
                unitCost = "¥" + serBun.unit_cost.ToString();
            }

            txt += $"<tr id='service{serBun.id}'>";
            txt += $"<td style='white - space:nowrap; '><img src = '../Images/delete.png' onclick='RemoveServiceBundle({serBun.id})' alt = '' /></ td > ";
            txt += $"<td><span>{serBun.name}</span></td>";
            txt += $"<td nowrap>{vendorName}</td>";
            txt += $"<td nowrap><span>{period}</span><input type='hidden' id='period{serBun.id}' value='{monthsPerPeriod}' ></td>";
            txt += $"<td nowrap align='right'><span>{unitCost}</span></td>";
            txt += $"<td nowrap align='right'>" + $"<input type='text' onblur='CalcService()' id='price{serBun.id}' name='price{serBun.id}' value = '{pricePerPeriod}' >" + "</ td > ";
            txt += $"<td nowrap align='right'>" + $"<input type='text' onblur='CalcService()' id='num{serBun.id}' name='num{serBun.id}' value = '1' >" + "</ td > ";
            txt += $"<td nowrap align='right'>¥" + $"<input type='text' id='pricenum{serBun.id}' value = '{pricePerPeriod}' disabled >" + "</ td > ";
            txt += "</tr>";

            result.Add(txt);
            result.Add(pricePerPeriod);
            result.Add(serBun.id);
            result.Add(monthsPerPeriod);

            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var account_id = Request.QueryString["account_id"];
                itemStartDatePara = Request.QueryString["stareDate"];
                itemEndDatePara   = Request.QueryString["endDate"];
                contractTypePara  = Request.QueryString["contract_type"];
                contractCatePara  = Request.QueryString["contract_cate"];
                projectItemPara   = Request.QueryString["itemDeal"];

                var thisProjectId = Request.QueryString["thisProject"];
                if (!string.IsNullOrEmpty(thisProjectId))
                {
                    thisProject = new pro_project_dal().FindNoDeleteById(long.Parse(thisProjectId));
                }
                if (thisProject != null)
                {
                    project_idHidden.Value = thisProject.id.ToString();
                }


                contract_udfList = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.CONTRACTS);
                account          = new CompanyBLL().GetCompany(long.Parse(account_id));

                if (!IsPostBack)
                {
                    PageDataBind();
                    if (!string.IsNullOrEmpty(itemStartDatePara))
                    {
                        itemStartDate.Value = itemStartDatePara;
                    }
                    if (!string.IsNullOrEmpty(itemEndDatePara))
                    {
                        itemEndDate.Value = itemEndDatePara;
                    }
                    if (!string.IsNullOrEmpty(contractTypePara))
                    {
                        contract_type_id.SelectedValue = contractTypePara;
                    }
                    if (!string.IsNullOrEmpty(contractCatePara))
                    {
                        contract_cate_id.SelectedValue = contractCatePara;
                    }
                    if (!string.IsNullOrEmpty(projectItemPara))
                    {
                    }

                    var childAccList = new crm_account_dal().GetSubsidiariesById(account.id);
                    if (childAccList != null && childAccList.Count > 0)
                    {
                        if (!string.IsNullOrEmpty(isCheckSunAccountPara))
                        {
                            ckchildAccounts.Checked = true;
                        }
                    }
                    else
                    {
                        ckchildAccounts.Enabled = false;
                    }
                }
            }
            catch (Exception)
            {
                Response.End();
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 根据第一页的查询条件,显示第二页的内容
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbnext_Click(object sender, EventArgs e)
        {
            var accountId           = account_idHidden.Value;
            var showChildAcc        = ckchildAccounts.Checked;
            var showserviceContract = ckserviceContract.Checked;
            var showFixPrice        = ckFixPrice.Checked;
            var showPriceZero       = ckPirceZero.Checked;
            var project_id          = project_idHidden.Value;
            var department          = department_id.SelectedValue;
            var startDate           = itemStartDate.Value;
            var endDate             = itemEndDate.Value;
            var contractType        = contract_type_id.SelectedValue;
            var contractCate        = contract_cate_id.SelectedValue;
            var project_item        = projectItem.SelectedValue;
            var type   = thisItemTypeId.Value; // 条目类型-多选--toTest
            var cadDal = new crm_account_deduction_dal();

            var chooseAccount = new CompanyBLL().GetCompany(long.Parse(accountId));

            if (chooseAccount == null)
            {
                return;
            }

            //accDedList = cadDal.GetAccDed(chooseAccount.id);  // 将要在页面上显示的条目
            //if (accDedList == null)
            //    accDedList = new List<crm_account_deduction>();

            StringBuilder sqlWhere = new StringBuilder();

            if (!string.IsNullOrEmpty(project_id))
            {
                sqlWhere.Append($" and project_id={project_id}");
            }
            if ((!string.IsNullOrEmpty(department)) && (department != "0"))
            {
                sqlWhere.Append($" and department_id={department}");
            }
            if (!string.IsNullOrEmpty(startDate))
            {
                sqlWhere.Append($" and item_date>='{startDate}'");
            }
            if (!string.IsNullOrEmpty(endDate))
            {
                sqlWhere.Append($" and item_date<='{endDate}'");
            }
            if (!string.IsNullOrEmpty(type))
            {
                sqlWhere.Append($" and item_type in ({type}) ");
            }
            if ((!string.IsNullOrEmpty(contractType)) && contractType != "0")
            {
                sqlWhere.Append($" and contract_type_id={contractType}");
            }
            if ((!string.IsNullOrEmpty(contractCate)) && contractCate != "0")
            {
                sqlWhere.Append($" and contract_cate_id={contractCate}");
            }
            if (project_item == "onlyProject")
            {
                sqlWhere.Append($" and project_id is not null");
            }
            if (project_item == "onlyNoProject")
            {
                sqlWhere.Append($" and project_id is null");
            }

            // todo 其余三个Show的过滤

            if (!showserviceContract)
            {
                sqlWhere.Append($" and (item_type in(1318,1319) and contract_type_id not in(1199) or  item_type not in(1318,1319) )");
            }
            if (!showFixPrice)
            {
                sqlWhere.Append($" and  (item_type in(1318,1319) and contract_type_id not in(1201) or  item_type not in(1318,1319) )");
            }
            if (showPriceZero)
            {
                sqlWhere.Append($" and dollars <>0");
            }

            List <InvoiceDeductionDto> deeList = null;
            var sortOrder = Request.QueryString["sortOrder"];

            switch (sortOrder)
            {
            case "1":        // 客户
                deeList = cadDal.GetInvDedDtoList(sqlWhere.ToString() + " and account_id=" + chooseAccount.id.ToString() + " and    invoice_id is null and purchase_order_no is null");
                break;

            case "2":        // ticket
                deeList = cadDal.GetInvDedDtoList(sqlWhere.ToString() + " and account_id=" + chooseAccount.id.ToString() + " and    invoice_id is null and purchase_order_no is null AND project_id is null");
                break;

            case "3":        // 项目
                var thisProject = Request.QueryString["thisProject"];
                deeList = cadDal.GetInvDedDtoList(sqlWhere.ToString() + " and account_id=" + chooseAccount.id.ToString() + " and    invoice_id is null and purchase_order_no is null AND project_id = " + thisProject);
                break;

            case "4":        // 采购订单
                var thisPurOrder = Request.QueryString["thisPurOrder"];
                if (!string.IsNullOrEmpty(thisPurOrder))
                {
                    thisPurOrder = thisPurOrder.Substring(5, thisPurOrder.Length - 5);
                    deeList      = cadDal.GetInvDedDtoList(sqlWhere.ToString() + " and account_id=" + chooseAccount.id.ToString() + " and    invoice_id is null and purchase_order_no =" + thisPurOrder);
                }
                break;

            default:
                break;
            }


            #region  加上子公司的条目
            if (showChildAcc) // 代表用户选中展示子客户条目
            {
                var childAccList = new crm_account_dal().GetSubsidiariesById(chooseAccount.id);
                if (childAccList != null && childAccList.Count > 0)
                {
                    foreach (var childAcc in childAccList)
                    {
                        var childAccDedList = cadDal.GetInvDedDtoList(sqlWhere.ToString() + " and account_id=" + childAcc.id);  //+ " and bill_account_id <>"+ chooseAccount.id
                        if (childAccDedList != null && childAccDedList.Count > 0)
                        {
                            childAccDedList.ForEach(_ => {
                                _.isSub = "1";
                            });
                            deeList.AddRange(childAccDedList); // 循环添加子客户条目
                        }
                    }
                }
            }
            StringBuilder dedHtml = new StringBuilder();
            if (deeList != null && deeList.Count > 0)
            {
                deeList = deeList.Distinct().ToList();
                foreach (var invDedDto in deeList)
                {
                    // 1 代表是不可选的子客户
                    // 2 待定 可选但是默认不选
                    var ischeck = invDedDto.isSub == "1" ? "disabled" : invDedDto.isSub == "2"?"": "checked";

                    var imgSrc = invDedDto.type_icon;         // 根据类型选择图片位置

                    var itemName       = invDedDto.item_name; // todo 部分有下标名
                    var rate           = invDedDto.rate == null ? "" : ((decimal)invDedDto.rate).ToString("#0.00");
                    var quantity       = invDedDto.quantity == null ? "" : ((decimal)invDedDto.quantity).ToString("#0.00");
                    var dollars        = invDedDto.dollars == null ? "" : ((decimal)invDedDto.dollars).ToString("#0.00");
                    var bill_to_parent = string.IsNullOrEmpty(invDedDto.bill_to_parent) ? "" : "√";
                    var bill_to_sub    = string.IsNullOrEmpty(invDedDto.bill_to_sub) ? "" : "√";

                    dedHtml.Append($"<tr><td align='center' style='width: 20px;'><input type='checkbox' class='thisDedCheck' style='margin: 0;' value='{invDedDto.id}' {ischeck}></td><td width='20px' align='center'><img src='{imgSrc}' /></td> <td width='20' align='center'>{invDedDto.item_date}</td><td>{itemName}</td><td>{invDedDto.account_name}</td><td>{invDedDto.contract_name}</td><td>{invDedDto.department_name}</td><td>{invDedDto.cost_code_name}</td><td>{invDedDto.resource_name}</td><td>{invDedDto.role_name}</td><td>{invDedDto.project_name}</td><td>{rate}</td><td>{quantity}</td><td>{dollars}</td><td>{invDedDto.tax_category_name}</td><td>{bill_to_parent}</td><td>{bill_to_sub}</td></tr>");
                    //showAccountDed
                }
                //ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script></script>");
            }


            ClientScript.RegisterStartupScript(this.GetType(), "页面跳转", "<script>document.getElementById('showAccountDed').innerHTML=\"" + dedHtml.ToString() + "\";document.getElementsByClassName('Workspace1')[0].style.display = 'none';document.getElementsByClassName('Workspace2')[0].style.display = '';document.getElementById('date_range_from').value=\"" + startDate + "\";document.getElementById('date_range_to').value=\"" + endDate + "\";</script>");

            #endregion
        }
Esempio n. 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();
            }
        }
Esempio n. 12
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();
            }
        }