Example #1
0
        protected string ImportDataItem(DataSet ds, ref int success, ref int error)//基础数据
        {
            string result = "";

            BLL.CCOM.Province             bll_Province             = new BLL.CCOM.Province();
            Model.CCOM.Province           model_Province           = new Model.CCOM.Province();
            BLL.CCOM.Politics             bll_Politics             = new BLL.CCOM.Politics();
            Model.CCOM.Politics           model_Politics           = new Model.CCOM.Politics();
            BLL.CCOM.Nationality          bll_Nationality          = new BLL.CCOM.Nationality();
            Model.CCOM.Nationality        model_Nationality        = new Model.CCOM.Nationality();
            BLL.CCOM.Nation               bll_Nation               = new BLL.CCOM.Nation();
            Model.CCOM.Nation             model_Nation             = new Model.CCOM.Nation();
            BLL.CCOM.Musical_instrument   bll_Musical_instrument   = new BLL.CCOM.Musical_instrument();
            Model.CCOM.Musical_instrument model_Musical_instrument = new Model.CCOM.Musical_instrument();
            BLL.CCOM.Degree               bll_Degree               = new BLL.CCOM.Degree();
            Model.CCOM.Degree             model_Degree             = new Model.CCOM.Degree();
            BLL.CCOM.Certificate_type     bll_Certificate_type     = new BLL.CCOM.Certificate_type();
            Model.CCOM.Certificate_type   model_Certificate_type   = new Model.CCOM.Certificate_type();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string checkmsg = null;
                string name     = ds.Tables[0].Rows[i]["名称"].ToString().Trim();
                if (!ValidDFValue(name, true, "", ref checkmsg))
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新失败,名称" + checkmsg + "<br/>";
                    error++;
                    continue;
                }
                switch (this.ddlResourceType.SelectedValue)
                {
                case "1":
                    if (name != "")
                    {
                        model_Province.Province_name = name;
                    }
                    if (bll_Province.GetModel(" Province_name='" + name + "'") != null)
                    {
                        result += "×第" + (i + 1).ToString() + "行,系统已存在该数据<br/>";
                        error++;
                        continue;
                    }
                    else if (bll_Province.Add(model_Province) == 0)
                    {
                        result += "×第" + (i + 1).ToString() + "行数据更新异常<br/>";
                        error++;
                        continue;
                    }
                    else
                    {
                        success++;
                    }
                    break;

                case "2":
                    if (name != "")
                    {
                        model_Politics.Politics_name = name;
                    }
                    if (bll_Politics.GetModel(" Politics_name='" + name + "'") != null)
                    {
                        result += "×第" + (i + 1).ToString() + "行,系统已存在该数据<br/>";
                        error++;
                        continue;
                    }
                    else if (bll_Politics.Add(model_Politics) == 0)
                    {
                        result += "×第" + (i + 1).ToString() + "行数据更新异常<br/>";
                        error++;
                        continue;
                    }
                    else
                    {
                        success++;
                    }
                    break;

                case "3":
                    if (name != "")
                    {
                        model_Nationality.Nationality_name = name;
                    }
                    if (bll_Nationality.GetModel(" Nationality_name='" + name + "'") != null)
                    {
                        result += "×第" + (i + 1).ToString() + "行,系统已存在该数据<br/>";
                        error++;
                        continue;
                    }
                    else if (bll_Nationality.Add(model_Nationality) == 0)
                    {
                        result += "×第" + (i + 1).ToString() + "行数据更新异常<br/>";
                        error++;
                        continue;
                    }
                    else
                    {
                        success++;
                    }
                    break;

                case "4":
                    if (name != "")
                    {
                        model_Nation.Nation_name = name;
                    }
                    if (bll_Nation.GetModel(" Nation_name='" + name + "'") != null)
                    {
                        result += "×第" + (i + 1).ToString() + "行,系统已存在该数据<br/>";
                        error++;
                        continue;
                    }
                    else if (bll_Nation.Add(model_Nation) == 0)
                    {
                        result += "×第" + (i + 1).ToString() + "行数据更新异常<br/>";
                        error++;
                        continue;
                    }
                    else
                    {
                        success++;
                    }
                    break;

                case "5":
                    if (name != "")
                    {
                        model_Musical_instrument.Mi_name = name;
                    }
                    if (bll_Musical_instrument.GetModel(" Mi_name='" + name + "'") != null)
                    {
                        result += "×第" + (i + 1).ToString() + "行,系统已存在该数据<br/>";
                        error++;
                        continue;
                    }
                    else if (bll_Musical_instrument.Add(model_Musical_instrument) == 0)
                    {
                        result += "×第" + (i + 1).ToString() + "行数据更新异常<br/>";
                        error++;
                        continue;
                    }
                    else
                    {
                        success++;
                    }
                    break;

                case "6":
                    if (name != "")
                    {
                        model_Degree.Degree_name = name;
                    }
                    if (bll_Degree.GetModel(" Degree_name='" + name + "'") != null)
                    {
                        result += "×第" + (i + 1).ToString() + "行,系统已存在该数据<br/>";
                        error++;
                        continue;
                    }
                    else if (bll_Degree.Add(model_Degree) == 0)
                    {
                        result += "×第" + (i + 1).ToString() + "行数据更新异常<br/>";
                        error++;
                        continue;
                    }
                    else
                    {
                        success++;
                    }
                    break;

                case "7":
                    if (name != "")
                    {
                        model_Certificate_type.Ct_name = name;
                    }
                    if (bll_Certificate_type.GetModel(" Ct_name='" + name + "'") != null)
                    {
                        result += "×第" + (i + 1).ToString() + "行,系统已存在该数据<br/>";
                        error++;
                        continue;
                    }
                    else if (bll_Certificate_type.Add(model_Certificate_type) == 0)
                    {
                        result += "×第" + (i + 1).ToString() + "行数据更新异常<br/>";
                        error++;
                        continue;
                    }
                    else
                    {
                        success++;
                    }
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            String select = this.ddlResourceType.SelectedValue;
            String name   = this.nameText.Text;

            if (name == "")
            {
                JscriptMsg("资源名称不能为空!", "", "Error");
                return;
            }
            if (select == "")
            {
                JscriptMsg("资源类型不能为空!", "", "Error");
                return;
            }
            if (Tools.CheckParams(name + select))
            {
                JscriptMsg("输入参数不合法!", "", "Error");
                return;
            }
            if (action == MyEnums.ActionEnum.Edit.ToString()) //修改
            {
                if (signId != 0)
                {
                    string pageUrl = Utils.CombUrlTxt("ResourceList.aspx", "fun_id={0}&selectid={1}",
                                                      DESEncrypt.Encrypt(this.fun_id), selectid);
                    switch (select)
                    {
                    case "1":
                        Model.CCOM.Province model_province = new BLL.CCOM.Province().GetModel(" Province_id=" + signId);
                        if (model_province != null)
                        {
                            model_province.Province_name = name;
                            if (new BLL.CCOM.Province().GetModel(" Province_name='" + name + "'") != null)
                            {
                                JscriptMsg("系统中已有该资源!", "", "Error");
                            }
                            else if (new BLL.CCOM.Province().Update(model_province))
                            {
                                JscriptMsg("生源地编辑成功!^_^", pageUrl, "Success");
                            }
                            else
                            {
                                JscriptMsg("出现异常,生源地编辑失败!", "", "Error");
                            }
                        }
                        break;

                    case "2":
                        Model.CCOM.Politics model_politics = new BLL.CCOM.Politics().GetModel(" Politics_id=" + signId);
                        if (model_politics != null)
                        {
                            model_politics.Politics_name = name;
                            if (new BLL.CCOM.Politics().GetModel(" Politics_name='" + name + "'") != null)
                            {
                                JscriptMsg("系统中已有该资源!", "", "Error");
                            }
                            else if (new BLL.CCOM.Politics().Update(model_politics))
                            {
                                JscriptMsg("政治面貌编辑成功!^_^", pageUrl, "Success");
                            }
                            else
                            {
                                JscriptMsg("出现异常,政治面貌编辑失败!", "", "Error");
                            }
                        }
                        break;

                    case "3":
                        Model.CCOM.Nationality model_nationality = new BLL.CCOM.Nationality().GetModel(" Nationality_id=" + signId);
                        if (model_nationality != null)
                        {
                            model_nationality.Nationality_name = name;
                            if (new BLL.CCOM.Nationality().GetModel(" Nationality_name='" + name + "'") != null)
                            {
                                JscriptMsg("系统中已有该资源!", "", "Error");
                            }
                            else if (new BLL.CCOM.Nationality().Update(model_nationality))
                            {
                                JscriptMsg("民族编辑成功!^_^", pageUrl, "Success");
                            }
                            else
                            {
                                JscriptMsg("出现异常,民族编辑失败!", "", "Error");
                            }
                        }
                        break;

                    case "4":
                        Model.CCOM.Nation model_nation = new BLL.CCOM.Nation().GetModel(" Nation_id=" + signId);
                        if (model_nation != null)
                        {
                            model_nation.Nation_name = name;
                            if (new BLL.CCOM.Nation().GetModel(" Nation_name='" + name + "'") != null)
                            {
                                JscriptMsg("系统中已有该资源!", "", "Error");
                            }
                            else if (new BLL.CCOM.Nation().Update(model_nation))
                            {
                                JscriptMsg("国籍编辑成功!^_^", pageUrl, "Success");
                            }
                            else
                            {
                                JscriptMsg("出现异常,国籍编辑失败!", "", "Error");
                            }
                        }
                        break;

                    case "5":
                        Model.CCOM.Musical_instrument model_musical_instrument = new BLL.CCOM.Musical_instrument().GetModel(" Mi_id=" + signId);
                        if (model_musical_instrument != null)
                        {
                            model_musical_instrument.Mi_name = name;
                            if (new BLL.CCOM.Musical_instrument().GetModel(" Mi_name='" + name + "'") != null)
                            {
                                JscriptMsg("系统中已有该资源!", "", "Error");
                            }
                            else if (new BLL.CCOM.Musical_instrument().Update(model_musical_instrument))
                            {
                                JscriptMsg("乐器编辑成功!^_^", pageUrl, "Success");
                            }
                            else
                            {
                                JscriptMsg("出现异常,乐器编辑失败!", "", "Error");
                            }
                        }
                        break;

                    case "6":
                        Model.CCOM.Degree model_degree = new BLL.CCOM.Degree().GetModel(" Degree_id=" + signId);
                        if (model_degree != null)
                        {
                            model_degree.Degree_name = name;
                            if (new BLL.CCOM.Degree().GetModel(" Degree_name='" + name + "'") != null)
                            {
                                JscriptMsg("系统中已有该资源!", "", "Error");
                            }
                            else if (new BLL.CCOM.Degree().Update(model_degree))
                            {
                                JscriptMsg("教育程度编辑成功!^_^", pageUrl, "Success");
                            }
                            else
                            {
                                JscriptMsg("出现异常,教育程度编辑失败!", "", "Error");
                            }
                        }
                        break;

                    case "7":
                        Model.CCOM.Certificate_type model_certificate_type = new BLL.CCOM.Certificate_type().GetModel(" Ct_id=" + signId);
                        if (model_certificate_type != null)
                        {
                            model_certificate_type.Ct_name = name;
                            if (new BLL.CCOM.Certificate_type().GetModel(" Ct_name='" + name + "'") != null)
                            {
                                JscriptMsg("系统中已有该资源!", "", "Error");
                            }
                            else if (new BLL.CCOM.Certificate_type().Update(model_certificate_type))
                            {
                                JscriptMsg("证件类型编辑成功!^_^", pageUrl, "Success");
                            }
                            else
                            {
                                JscriptMsg("出现异常,证件类型编辑失败!", "", "Error");
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                //add
                string pageUrl = Utils.CombUrlTxt("ResourceList.aspx", "fun_id={0}&selectid={1}", DESEncrypt.Encrypt(this.fun_id), select);
                int    id      = 0;
                switch (select)
                {
                case "1":
                    Model.CCOM.Province model_province = new Model.CCOM.Province();
                    model_province.Province_name = name;
                    if (new BLL.CCOM.Province().GetModel(" Province_name='" + name + "'") != null)
                    {
                        id = -100;
                    }
                    else
                    {
                        id = new BLL.CCOM.Province().Add(model_province);
                    }
                    break;

                case "2":
                    Model.CCOM.Politics model_politics = new Model.CCOM.Politics();
                    model_politics.Politics_name = name;
                    if (new BLL.CCOM.Politics().GetModel(" Politics_name='" + name + "'") != null)
                    {
                        id = -100;
                    }
                    else
                    {
                        id = new BLL.CCOM.Politics().Add(model_politics);
                    }
                    break;

                case "3":
                    Model.CCOM.Nationality model_nationality = new Model.CCOM.Nationality();
                    model_nationality.Nationality_name = name;
                    if (new BLL.CCOM.Nationality().GetModel(" Nationality_name='" + name + "'") != null)
                    {
                        id = -100;
                    }
                    else
                    {
                        id = new BLL.CCOM.Nationality().Add(model_nationality);
                    }
                    break;

                case "4":
                    Model.CCOM.Nation model_nation = new Model.CCOM.Nation();
                    model_nation.Nation_name = name;
                    if (new BLL.CCOM.Nation().GetModel(" Nation_name='" + name + "'") != null)
                    {
                        id = -100;
                    }
                    else
                    {
                        id = new BLL.CCOM.Nation().Add(model_nation);
                    }
                    break;

                case "5":
                    Model.CCOM.Musical_instrument model_musical_instrument = new Model.CCOM.Musical_instrument();
                    model_musical_instrument.Mi_name = name;
                    if (new BLL.CCOM.Musical_instrument().GetModel(" Mi_name='" + name + "'") != null)
                    {
                        id = -100;
                    }
                    else
                    {
                        id = new BLL.CCOM.Musical_instrument().Add(model_musical_instrument);
                    }
                    break;

                case "6":
                    Model.CCOM.Degree model_degree = new Model.CCOM.Degree();
                    model_degree.Degree_name = name;
                    if (new BLL.CCOM.Degree().GetModel(" Degree_name='" + name + "'") != null)
                    {
                        id = -100;
                    }
                    else
                    {
                        id = new BLL.CCOM.Degree().Add(model_degree);
                    }
                    break;

                case "7":
                    Model.CCOM.Certificate_type model_certificate_type = new Model.CCOM.Certificate_type();
                    model_certificate_type.Ct_name = name;
                    if (new BLL.CCOM.Certificate_type().GetModel(" Ct_name='" + name + "'") != null)
                    {
                        id = -100;
                    }
                    else
                    {
                        id = new BLL.CCOM.Certificate_type().Add(model_certificate_type);
                    }
                    break;

                default:
                    break;
                }
                if (id > 0)
                {
                    JscriptMsg("添加资源成功!^_^", pageUrl, "Success");
                }
                else if (id == -100)
                {
                    JscriptMsg("系统中已有该资源!", "", "Error");
                }
                else
                {
                    JscriptMsg("出现异常,添加资源失败!", "", "Error");
                }
            }
        }