Exemplo n.º 1
0
    /// <summary>
    /// 保存系统设置信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Settings(string str)
    {
        JsonData JInfo = JsonMapper.ToObject(str);

        string bind = "{\"ds\":\"1\",\"prompt\":\"提交失败\"}";

        if (JInfo.Count < 0)
        {
            Response.Write(bind);
            Response.End();
        }

        StringBuilder strSql = new StringBuilder();

        SqlTransaction TranSaction = null;
        SqlConnection  Connection  = new SqlConnection(SqlHelper.LocalSqlServer);

        Connection.Open();
        TranSaction = Connection.BeginTransaction();

        try
        {
            //查询该企业的设置
            List <Hi.Model.SYS_SysName> Sysl = new Hi.BLL.SYS_SysName().GetList("", " CompID=" + CompID, "");
            int d = 0;

            //判断企业的是否有设置
            if (Sysl != null && Sysl.Count > 0)
            {
                for (int i = 0; i <= JInfo.Count - 1; i++)
                {
                    JsonData j = JInfo[i];
                    //系统设置的标题
                    string key = Common.NoHTML(j["key"].ToString());
                    //系统设置的值
                    string val = Common.NoHTML(j["val"].ToString());


                    //if (key == "商品是否启用库存")
                    //{
                    //    List<Hi.Model.DIS_Order> l = new Hi.BLL.DIS_Order().GetList("", " compID=" + CompID + " and OState in(1,2) and isnull(dr,0)=0", "");
                    //    if (l != null && l.Count > 0)
                    //    {
                    //        d = 1;
                    //        continue;
                    //    }
                    //}

                    List <Hi.Model.SYS_SysName> sl = Sysl.FindAll(p => p.Name == key);
                    if (sl != null && sl.Count > 0)
                    {
                        strSql.AppendFormat("update SYS_SysName set Value='{0}',ts='{1}' where Name='{2}' and CompID={3};", val, DateTime.Now.AddDays(-1), key, CompID);
                    }
                    else
                    {
                        strSql.AppendFormat("INSERT INTO [SYS_SysName]([CompID],[Code],[Name],[Value],[ts],[dr],[modifyuser])VALUES({0},'','{1}','{2}','{3}',0,{4});", CompID, key, val, DateTime.Now.AddDays(-1), UserID);
                    }
                }
            }
            else
            {
                for (int i = 0; i <= JInfo.Count - 1; i++)
                {
                    JsonData j = JInfo[i];

                    //系统设置的标题
                    string key = Common.NoHTML(j["key"].ToString());
                    //系统设置的值
                    string val = Common.NoHTML(j["val"].ToString());

                    strSql.AppendFormat("INSERT INTO [SYS_SysName]([CompID],[Code],[Name],[Value],[ts],[dr],[modifyuser])VALUES({0},'','{1}','{2}','{3}',0,{4});", CompID, key, val, DateTime.Now.AddDays(-1), UserID);
                }
            }

            SqlCommand cmd = new SqlCommand(strSql.ToString(), Connection, TranSaction);
            cmd.CommandType = CommandType.Text;
            int rowsAffected = SqlHelper.GetInt(cmd.ExecuteNonQuery().ToString());
            if (rowsAffected > 0)
            {
                TranSaction.Commit();

                //if (d == 1)
                //    bind = "{\"ds\":\"0\",\"prompt\":\"订单没有处理完成,修改商品启用库存失败!\"}";
                //else
                bind = "{\"ds\":\"0\",\"prompt\":\"提交成功!\"}";
            }
            else
            {
                TranSaction.Rollback();
                bind = "{\"ds\":\"1\",\"prompt\":\"提交失败!\"}";
            }
        }
        catch (Exception ex)
        {
            TranSaction.Rollback();
            bind = "{\"ds\":\"1\",\"prompt\":\"提交失败!\"}";
        }
        finally
        {
            Connection.Dispose();

            Response.Write(bind);

            Response.End();
        }
    }
Exemplo n.º 2
0
    protected void databind()
    {
        if (Session["UserModel"] is LoginModel)
        {
            #region 权限
            LoginModel model = Session["UserModel"] as LoginModel;

            bool isbte = false;
            ////返利
            List <Hi.Model.SYS_SysName> Sysl = new Hi.BLL.SYS_SysName().GetList("", " CompID=" + model.CompID, "");
            Sysl = Sysl.FindAll(p => p.Name == "订单支付返利是否启用");
            if (Sysl != null && Sysl.Count > 0)
            {
                isbte = Sysl[0].Value.ToString() == "1";
            }
            else
            {
                isbte = false;
            }
            ////是否启用库存
            this.spwhgl.Visible = OrderInfoType.rdoOrderAudit("商品是否启用库存", model.CompID) == "0" ? true : false;

            Erptype = model.Erptype;
            if (model != null)
            {
                //获得用户类型
                Hi.Model.SYS_Users sysUser = new Hi.BLL.SYS_Users().GetModel(model.UserID);
                if (sysUser != null && Common.HasAdminRole(sysUser.ID))
                {
                    //订单
                    //ddgl.Visible = true;
                    ddlb.Visible = true;
                    //ddsh.Visible = true;
                    //ddfh.Visible = true;
                    //ddth.Visible = true;

                    //收款
                    // ddskbl.Visible = true;
                    ddskmx.Visible = true;

                    //zdskbl.Visible = true;
                    //zdskmx.Visible = true;

                    //qbcx.Visible = true;

                    //ddsk.Visible = true;
                    //zdsk.Visible = true;
                    //qyqb.Visible = true;

                    //商品
                    splb.Visible   = true;
                    spfl.Visible   = true;
                    spsxwh.Visible = true;
                    spggmb.Visible = true;

                    spkc.Visible = true;
                    sprk.Visible = true;
                    spck.Visible = true;
                    sppd.Visible = false;
                    Dd3.Visible  = true;

                    //jxsjg.Visible = true;
                    //spbks.Visible = true;
                    spcx.Visible = true;
                    ddcx.Visible = true;

                    //代理商
                    jxslb.Visible  = true;
                    jxssh.Visible  = true;
                    jxsgly.Visible = true;

                    jxsfl.Visible = true;
                    jxsqy.Visible = true;
                    //dlssyzl.Visible = true;

                    //我的报表
                    ddtj.Visible   = true;
                    jxstj.Visible  = true;
                    sptj.Visible   = true;
                    zltj.Visible   = true;
                    spxsmx.Visible = true;

                    //sjfx.Visible = true;
                    //zhfx.Visible = true;
                    //ddfx.Visible = true;
                    //jxsfx.Visible = true;
                    //cpfx.Visible = true;
                    //cpabcfx.Visible = true;
                    //ysfx.Visible = true;

                    //设置
                    skzhgl.Visible = true;
                    gwqxwh.Visible = true;
                    ygzhwh.Visible = true;
                    xgdlmm.Visible = true;
                    xtsz.Visible   = true;

                    xxfb.Visible  = true;
                    lyhf.Visible  = true;
                    qyxx.Visible  = true;
                    xsywh.Visible = true;
                    dply.Visible  = true;
                    dpxx.Visible  = true;
                    dpwh.Visible  = true;


                    //商品
                    spxx.Visible = true;
                    //spwh.Visible = true;
                    spcxgl.Visible = true;
                    //代理商
                    jxsxx.Visible = true;
                    jsxsz.Visible = true;
                    //设置
                    jbsz.Visible = true;
                    xxwh.Visible = true;
                    wddp.Visible = true;

                    //招商
                    zslb.Visible  = true;
                    sylb.Visible  = true;
                    dlssy.Visible = true;
                    wdsy.Visible  = true;

                    //合同
                    htlb.Visible = true;


                    //我的桌面
                    //wdzm.Visible = true;

                    ddglHref.Attributes["href"] = ResolveUrl("../Order/OrderCreateList.aspx");
                    //ddskHref.Attributes["href"] = ResolveUrl("../Report/CompCollection.aspx");
                    goodsHref.Attributes["href"]  = ResolveUrl("../GoodsNew/GoodsList.aspx");
                    disHref.Attributes["href"]    = ResolveUrl("../SysManager/DisList.aspx");
                    reportHref.Attributes["href"] = ResolveUrl("../Report/CustSaleRpt.aspx");
                    sysHref.Attributes["href"]    = ResolveUrl("../Pay/PayAccountList.aspx");

                    htHref.Attributes["href"] = ResolveUrl("../Contract/ContractList.aspx");
                }
                else
                {
                    //string sql = "select rf.FunCode from SYS_RoleSysFun rf join SYS_CompUser u on u.RoleID=rf.RoleID where u.UserID=" + model.UserID;
                    //DataTable dt = SqlHelper.Query(SqlHelper.LocalSqlServer, sql).Tables[0];
                    List <Hi.Model.SYS_RoleSysFun> list = new Hi.BLL.SYS_RoleSysFun().GetList(" FunCode ", " CompID=" + model.CompID + " AND  RoleID IN (SELECT RoleID FROM dbo.SYS_RoleUser WHERE UserID=" + model.UserID + " AND IsEnabled=1 AND dr=0) GROUP BY FunCode ", "");
                    for (int i = 0; i < list.Count; i++)
                    {
                        string code = list[i].FunCode.ToString();
                        switch (code)
                        {
                        //订单
                        case "10":
                            ddglHref.Attributes["href"] = ResolveUrl("../Order/OrderCreateList.aspx");
                            break;

                        case "1011":
                            ddlb.Visible = true;
                            break;

                        case "1111":
                            ddskmx.Visible = true;
                            break;
                        //case "1112":
                        //    zdskbl.Visible = true;
                        //    break;
                        //case "1114":
                        //    zdskmx.Visible = true;
                        //    break;
                        //case "1115":
                        //    qbcx.Visible = true;
                        //    break;


                        //商品
                        case "12":
                            goodsHref.Attributes["href"] = ResolveUrl("../GoodsNew/GoodsInfoList.aspx");
                            break;

                        case "1210":
                            splb.Visible = true;
                            break;

                        case "1213":
                            spkc.Visible = true;
                            break;

                        case "1214":
                            spfl.Visible = true;
                            break;

                        //case "1215":
                        //    jxsjg.Visible = true;
                        //    break;
                        case "1216":
                            spsxwh.Visible = true;
                            break;

                        case "1217":
                            spggmb.Visible = true;
                            break;

                        //case "1218":
                        //    spbks.Visible = true;
                        //    break;
                        case "1219":
                            spcx.Visible = true;
                            break;

                        case "1220":
                            spkc.Visible = true;
                            break;

                        case "1221":
                            sprk.Visible = true;
                            break;

                        case "1223":
                            spck.Visible = true;
                            break;

                        case "1225":
                            sppd.Visible = false;
                            break;

                        case "1227":
                            Dd3.Visible = true;
                            break;

                        case "1232":
                            spcx.Visible = true;
                            break;

                        case "1233":
                            ddcx.Visible = true;
                            break;

                        //代理商
                        case "13":
                            disHref.Attributes["href"] = ResolveUrl("../SysManager/DisList.aspx");
                            break;

                        case "1310":
                            jxslb.Visible = true;
                            break;

                        case "1312":
                            jxssh.Visible = true;
                            break;

                        case "1314":
                            jxsgly.Visible = true;
                            break;

                        case "1315":
                            jxsfl.Visible = true;
                            break;

                        case "1316":
                            jxsqy.Visible = true;
                            break;


                        //我的报表
                        case "14":
                            reportHref.Attributes["href"] = ResolveUrl("../Report/CustSaleRpt.aspx");
                            break;

                        case "1410":
                            ddtj.Visible = true;
                            break;

                        case "1411":
                            jxstj.Visible = true;
                            break;

                        case "1412":
                            sptj.Visible = true;
                            break;

                        case "1413":
                            zltj.Visible = true;
                            break;

                        case "1414":
                            spxsmx.Visible = true;
                            break;
                        //case "1416":
                        //    zhfx.Visible = true;
                        //    break;
                        //case "1417":
                        //    ddfx.Visible = true;
                        //    break;
                        //case "1418":
                        //    jxsfx.Visible = true;
                        //    break;
                        //case "1419":
                        //    cpfx.Visible = true;
                        //    break;
                        //case "1420":
                        //    cpabcfx.Visible = true;
                        //    break;
                        //case "1421":
                        //    ysfx.Visible = true;
                        //    break;

                        //设置
                        case "15":
                            sysHref.Attributes["href"] = ResolveUrl("../Pay/PayAccountList.aspx");
                            break;

                        case "1510":
                            skzhgl.Visible = true;
                            break;

                        case "1511":
                            gwqxwh.Visible = true;
                            break;

                        case "1512":
                            ygzhwh.Visible = true;
                            break;

                        case "1513":
                            xtsz.Visible = true;
                            break;

                        case "1514":
                            xxfb.Visible = true;
                            break;

                        case "1515":
                            lyhf.Visible = true;
                            break;

                        case "1516":
                            qyxx.Visible = true;
                            break;

                        case "1517":
                            xsywh.Visible = true;
                            break;

                        case "1518":
                            dpxx.Visible = true;
                            break;

                        case "1519":
                            dpwh.Visible = true;
                            break;

                        case "1520":
                            dply.Visible = true;
                            break;

                        //招商
                        case "16":
                            //zsHref.Attributes["href"] = ResolveUrl("../CMerchants/CMerchantsList.aspx");
                            break;

                        case "1611":
                            zslb.Visible = true;
                            break;

                        case "1614":
                            sylb.Visible = true;
                            break;

                        case "1617":
                            dlssy.Visible = true;
                            break;

                        case "1618":
                            wdsy.Visible = true;
                            break;

                        //合同
                        case "17":
                            htHref.Attributes["href"] = ResolveUrl("../Contract/ContractList.aspx");
                            break;

                        case "1711":
                            htlb.Visible = true;
                            break;
                        }
                        string[] OrderCode = new string[] { "1011", "1012", "1013", "1015" };
                        if (OrderCode.Contains(code))
                        {
                            ddglHref.Attributes["href"] = ResolveUrl("../Order/OrderCreateList.aspx");
                        }
                    }

                    //我的桌面
                    //wdzm.Style.Add("display", "none;");
                    //我要开通
                    //ktwykt.Style.Add("display", "none;");
                }
                //我要维护,修改登录密码
                xgdlmm.Visible = true;
                //gmfw.Visible = true;
            }
            #endregion
        }
    }