示例#1
0
    private string GetContractLimitsByContractTypeAndPrj(string contractTypeID, string prjId)
    {
        System.Collections.Generic.List <string> UserCodes = new System.Collections.Generic.List <string>();
        System.Collections.Generic.List <string> ztbUsers  = (System.Collections.Generic.List <string>) new PTPrjInfoZTBUserService().GetUser(prjId);
        System.Collections.Generic.List <string> userCodesByIDThroughPrjProperty = new PTPrjInfoZTBDetailService().getUserCodesByIDThroughPrjProperty(prjId);
        System.Collections.Generic.List <string> userCode2 = new PrivBusiDataRoleService().GetUserCode(prjId);
        ConContractType byID = new ConContractTypeService().GetByID(contractTypeID);

        System.Collections.Generic.List <string> ContractTypeUsers = JsonHelper.GetListFromJson(byID.UserCodes);
        userCodesByIDThroughPrjProperty.ForEach(delegate(string userCode)
        {
            if (!ztbUsers.Contains(userCode))
            {
                ztbUsers.Add(userCode);
            }
        });
        userCode2.ForEach(delegate(string userCode)
        {
            if (!ztbUsers.Contains(userCode))
            {
                ztbUsers.Add(userCode);
            }
        });
        if (ztbUsers.Count >= ContractTypeUsers.Count)
        {
            ContractTypeUsers.ForEach(delegate(string userCode)
            {
                if (ztbUsers.Contains(userCode))
                {
                    UserCodes.Add(userCode);
                }
            });
        }
        else
        {
            ztbUsers.ForEach(delegate(string userCode)
            {
                if (ContractTypeUsers.Contains(userCode))
                {
                    UserCodes.Add(userCode);
                }
            });
        }
        if (!UserCodes.Contains("00000000"))
        {
            UserCodes.Add("00000000");
        }
        if (!UserCodes.Contains(base.UserCode))
        {
            UserCodes.Add(base.UserCode);
        }
        return(JsonHelper.Serialize(UserCodes.ToArray()));
    }
示例#2
0
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        ConContractTypeService conContractTypeService = new ConContractTypeService();
        ConContractType        conContractType        = new ConContractType();

        if (string.Compare(this.action, "Add", true) == 0)
        {
            conContractType = conContractTypeService.GetContractTypeByTypeName(this.txtTypeName.Text.Trim());
            if (conContractType != null)
            {
                base.RegisterScript("top.ui.alert('合同类型名称已经存在!')");
                return;
            }
            conContractType = conContractTypeService.GetContractTypeByTypeShort(this.txtTypeShort.Text.Trim());
            if (conContractType != null)
            {
                base.RegisterScript("top.ui.alert('合同类型简写已经存在!')");
                return;
            }
            ContractTypeModel contractTypeModel = new ContractTypeModel();
            contractTypeModel.TypeID   = System.Guid.NewGuid().ToString();
            contractTypeModel.TypeCode = this.txtTypeCode.Text.Trim();
            contractTypeModel.TypeName = this.txtTypeName.Text.Trim();
            if (base.UserCode == "00000000")
            {
                contractTypeModel.UserCodes = JsonHelper.Serialize(new string[]
                {
                    "00000000"
                });
            }
            else
            {
                contractTypeModel.UserCodes = JsonHelper.Serialize(new string[]
                {
                    "00000000",
                    base.UserCode
                });
            }
            contractTypeModel.Notes       = this.txtNotes.Text.Trim();
            contractTypeModel.InputPerson = this.txtInputPerson.Text;
            contractTypeModel.InputDate   = new System.DateTime?(System.Convert.ToDateTime(this.txtInputDate.Text));
            contractTypeModel.TypeShort   = this.txtTypeShort.Text.Trim();
            if (!string.IsNullOrEmpty(this.ddlCBS.SelectedValue.Trim()))
            {
                contractTypeModel.CBSCode = this.ddlCBS.SelectedValue.Trim();
            }
            else
            {
                contractTypeModel.CBSCode = null;
            }
            try
            {
                this.contractType.Add(contractTypeModel);
                base.RegisterScript("top.ui.tabSuccess({ parentName: '_ContractTypeEdit' });");
                return;
            }
            catch (System.Exception)
            {
                base.RegisterScript("top.ui.alert('添加失败')");
                return;
            }
        }
        string text    = base.Request["TypeID"].ToString();
        string cmdText = string.Concat(new string[]
        {
            "SELECT * FROM Con_ContractType WHERE TypeID not in('",
            text,
            "') and TypeName='",
            this.txtTypeName.Text.Trim(),
            "'"
        });
        DataTable dataTable = conContractTypeService.ExecuteQuery(cmdText, null);

        if (dataTable.Rows.Count > 0)
        {
            base.RegisterScript("top.ui.alert('合同类型名称已经存在!')");
            return;
        }
        cmdText = string.Concat(new string[]
        {
            "SELECT * FROM Con_ContractType WHERE TypeID not in('",
            text,
            "') and TypeShort='",
            this.txtTypeShort.Text.Trim(),
            "'"
        });
        dataTable = conContractTypeService.ExecuteQuery(cmdText, null);
        if (dataTable.Rows.Count > 0)
        {
            base.RegisterScript("top.ui.alert('合同类型简写已经存在!')");
            return;
        }
        ContractTypeModel model = this.contractType.GetModel(text);

        model.TypeCode  = this.txtTypeCode.Text.Trim();
        model.TypeName  = this.txtTypeName.Text.Trim();
        model.Notes     = this.txtNotes.Text.Trim();
        model.TypeShort = this.txtTypeShort.Text.Trim();
        if (!string.IsNullOrEmpty(this.ddlCBS.SelectedValue.Trim()))
        {
            model.CBSCode = this.ddlCBS.SelectedValue.Trim();
        }
        else
        {
            model.CBSCode = null;
        }
        try
        {
            this.contractType.Update(model);
            base.RegisterScript("top.ui.tabSuccess({ parentName: '_ContractTypeEdit' });");
        }
        catch (System.Exception)
        {
            base.RegisterScript("top.ui.alert('添加失败')");
        }
    }