コード例 #1
0
ファイル: ZXSHMag.cs プロジェクト: freedomxuli/chbappweb
 public object ZXFQ(string userId, int iscanrealese)
 {
     using (DBConnection dbc = new DBConnection())
     {
         dbc.BeginTransaction();
         try
         {
             var dt  = dbc.GetEmptyDataTable("tb_b_user");
             var dtt = new SmartFramework4v2.Data.DataTableTracker(dt);
             var sr  = dt.NewRow();
             sr["UserID"]         = new Guid(userId);
             sr["IsCanRelease"]   = iscanrealese;
             sr["canReleaseTime"] = DateTime.Now;
             dt.Rows.Add(sr);
             dbc.UpdateTable(dt, dtt);
             dbc.CommitTransaction();
             return(true);
         }
         catch (Exception ex)
         {
             dbc.RoolbackTransaction();
             throw ex;
         }
     }
 }
コード例 #2
0
ファイル: Goods.cs プロジェクト: freedomxuli/chbappweb
    public void SaveGoods(JSReader jsr)
    {
        if (string.IsNullOrEmpty(jsr["goodstypeid"].ToString()))
        {
            throw new Exception("货品类别不能为空");
        }
        if (jsr["goodsname"].IsNull || jsr["goodsname"].IsEmpty)
        {
            throw new Exception("货品名称不能为空");
        }

        using (MySqlDbConnection dbc = MySqlConnstr.GetDBConnection())
        {
            try
            {
                if (string.IsNullOrEmpty(jsr["goodsid"].ToString()))
                {
                    var goodsid = Guid.NewGuid().ToString();
                    var dt      = dbc.GetEmptyDataTable("tb_b_goods");
                    var dr      = dt.NewRow();
                    dr["goodsid"]    = goodsid;
                    dr["goodsname"]  = jsr["goodsname"].ToString();
                    dr["goodstype"]  = jsr["goodstypeid"].ToString();
                    dr["status"]     = 0;
                    dr["adduser"]    = SystemUser.CurrentUser.UserID;
                    dr["addtime"]    = DateTime.Now;
                    dr["updateuser"] = SystemUser.CurrentUser.UserID;
                    dr["updatetime"] = DateTime.Now;
                    dt.Rows.Add(dr);
                    dbc.InsertTable(dt);
                }
                else
                {
                    var dt  = dbc.GetEmptyDataTable("tb_b_goods");
                    var dtt = new SmartFramework4v2.Data.DataTableTracker(dt);
                    var dr  = dt.NewRow();
                    dr["goodsid"]    = jsr["goodsid"].ToString();
                    dr["goodsname"]  = jsr["goodsname"].ToString();
                    dr["goodstype"]  = jsr["goodstypeid"].ToString();
                    dr["updateuser"] = SystemUser.CurrentUser.UserID;
                    dr["updatetime"] = DateTime.Now;
                    dt.Rows.Add(dr);
                    dbc.UpdateTable(dt, dtt);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
コード例 #3
0
ファイル: Goods.cs プロジェクト: freedomxuli/chbappweb
    public object UploadPriceModel(FileData[] fds, string goodsid, string goodsname, string goodstypeid)
    {
        using (MySqlDbConnection dbc = MySqlConnstr.GetDBConnection())
        {
            try
            {
                dbc.BeginTransaction();
                string str = "";
                if (fds[0].FileBytes.Length == 0)
                {
                    throw new Exception("你上传的文件可能已被打开,请关闭该文件!");
                }
                System.IO.MemoryStream ms = new System.IO.MemoryStream(fds[0].FileBytes);
                Workbook  workbook        = new Workbook(ms);
                Worksheet sheet           = workbook.Worksheets[0];
                Cells     cells           = sheet.Cells;
                //foreach (Cell cell in cells)
                //{
                //    if (cell.IsMerged == true)
                //    {
                //        Range range = cell.GetMergedRange();
                //        cell.Value = cells[range.FirstRow, range.FirstColumn].Value;
                //    }
                //    else
                //    {
                //        cell.Value = cell.Value;
                //    }
                //}
                DataTable mydt = cells.ExportDataTableAsString(2, 0, cells.MaxRow + 1, cells.MaxColumn + 1);
                //数据准备
                string    sql    = "select * from tb_b_area ";
                DataTable arasDt = dbc.ExecuteDataTable(sql);

                sql = "select * from tb_b_dictionary_detail";
                DataTable dicDt = dbc.ExecuteDataTable(sql);
                //遍历验证
                for (int i = 0; i < mydt.Rows.Count; i++)
                {
                    DataRow dr = mydt.Rows[i];
                    if (!string.IsNullOrEmpty(dr[2].ToString()))
                    {
                        string _goodstypeid    = dr[0].ToString().Trim();
                        string _goodsid        = dr[1].ToString().Trim();
                        string _statisticstype = (string.IsNullOrEmpty(dr[2].ToString().Trim())) ? "" : (dr[2].ToString().Trim() == "零担" ? "1" : "2");//运输类型(只能是零担/整车)
                        //= dr[3].ToString();//起始地(省市区三个列)
                        //= dr[4].ToString();
                        string _fromroutecode = "";
                        string _fromroutename = dr[5].ToString().Trim();
                        if (!string.IsNullOrEmpty(_fromroutename))
                        {
                            _fromroutecode = arasDt.Select("name='" + _fromroutename + "'")[0]["code"].ToString();
                        }
                        //= dr[6].ToString();//目的地(省市区三个列)
                        //= dr[7].ToString();
                        string _toroutecode = "";
                        string _toroutename = dr[8].ToString().Trim();
                        if (!string.IsNullOrEmpty(_toroutename))
                        {
                            _toroutecode = arasDt.Select("name='" + _toroutename + "'")[0]["code"].ToString();
                        }
                        string    _frompart = dr[9].ToString().Trim();                                                                                                 //范围起始值
                        string    _topart   = dr[10].ToString().Trim();                                                                                                //范围结束值
                        string    _vehicletyperequirement   = (string.IsNullOrEmpty(dr[11].ToString().Trim())) ? "" : (dr[11].ToString().Trim() == "栏板车" ? "1" : "2"); //车型(栏板车/厢车)
                        string    _vehiclelengthrequirement = "";                                                                                                      //车长
                        DataRow[] ccDrs = dicDt.Select("name=" + dr[12].ToString().Trim());
                        if (ccDrs.Length > 0)
                        {
                            _vehiclelengthrequirement = ccDrs[0]["bm"].ToString();
                        }
                        string _price        = dr[13].ToString().Trim(); //单价
                        string _pickprice    = dr[14].ToString().Trim(); //提货价
                        string _deliverprice = dr[15].ToString().Trim(); //送货价

                        #region 验证
                        switch (_statisticstype)
                        {
                        case "1":    //如果运输类型为零担,起始地,目的地,范围起始值,范围结束值,单价,提货价,送货价为必填
                            if (string.IsNullOrEmpty(_fromroutename))
                            {
                                str = "请填写起始地!";
                            }
                            if (string.IsNullOrEmpty(_toroutename))
                            {
                                str = "请填写目的地!";
                            }
                            if (string.IsNullOrEmpty(_frompart))
                            {
                                str = "请填写范围起始值!";
                            }
                            if (string.IsNullOrEmpty(_topart))
                            {
                                str = "请填写范围结束值!";
                            }
                            if (string.IsNullOrEmpty(_price))
                            {
                                str = "请填写单价!";
                            }
                            if (string.IsNullOrEmpty(_pickprice))
                            {
                                str = "请填写提货价!";
                            }
                            if (string.IsNullOrEmpty(_deliverprice))
                            {
                                str = "请填写送货价!";
                            }
                            break;

                        case "2":    //如果运输类型为整车,起始地(省市区三个列),目的地(省市区三个列),车型,车长,单价,提货价,送货价为必填
                            if (string.IsNullOrEmpty(_fromroutename))
                            {
                                str = "请填写起始地!";
                            }
                            if (string.IsNullOrEmpty(_toroutename))
                            {
                                str = "请填写目的地!";
                            }
                            if (string.IsNullOrEmpty(_vehicletyperequirement))
                            {
                                str = "请填写车型!";
                            }
                            if (string.IsNullOrEmpty(_vehiclelengthrequirement))
                            {
                                str = "请填写车长!";
                            }
                            if (string.IsNullOrEmpty(_price))
                            {
                                str = "请填写单价!";
                            }
                            if (string.IsNullOrEmpty(_pickprice))
                            {
                                str = "请填写提货价!";
                            }
                            if (string.IsNullOrEmpty(_deliverprice))
                            {
                                str = "请填写送货价!";
                            }
                            break;
                        }
                        #endregion

                        if (!string.IsNullOrEmpty(str))
                        {
                            throw new Exception("你上传的文件填写数据有误【" + (i + 3) + "行" + str + "】");
                        }

                        #region 数据添加或修改

                        /**导入时先根据goodstypeid,goodsid,运输类型,起始地,目的地,车型,车长搜索一下,
                         * 如果存在,则更新单价,提货价,送货价,
                         * 如果不存在,则插入新的数据,省市区要查询地区表,查询转换成code插入对应地区编号
                         */
                        string _id = Verify(_goodstypeid, _goodsid, _statisticstype, _fromroutecode, _toroutecode, _vehicletyperequirement, _vehiclelengthrequirement);
                        if (!string.IsNullOrEmpty(_id))
                        {
                            //这里还需判断导入表货物与表货物一致
                            if (_goodstypeid != goodstypeid || _goodsid != goodsid)
                            {
                                throw new Exception("你上传的文件填写数据有误【当前表数据与货物不一致】");
                            }
                            var dt   = dbc.GetEmptyDataTable("tb_b_pricemodel");
                            var dtt  = new SmartFramework4v2.Data.DataTableTracker(dt);
                            var upDr = dt.NewRow();
                            upDr["id"]            = _id;
                            upDr["goodsname"]     = goodsname;
                            upDr["goodstypeid"]   = _goodstypeid;
                            upDr["goodsid"]       = _goodsid;
                            upDr["fromroutecode"] = _fromroutecode;
                            upDr["fromroutename"] = _fromroutename;
                            upDr["toroutecode"]   = _toroutecode;
                            upDr["toroutename"]   = _toroutename;
                            upDr["price"]         = !string.IsNullOrEmpty(_price) ? Convert.ToDecimal(_price) : 0m;
                            upDr["pickprice"]     = !string.IsNullOrEmpty(_pickprice) ? Convert.ToDecimal(_pickprice) : 0m;
                            upDr["deliverprice"]  = !string.IsNullOrEmpty(_deliverprice) ? Convert.ToDecimal(_deliverprice) : 0m;
                            if (!string.IsNullOrEmpty(_frompart))
                            {
                                upDr["frompart"] = _frompart;
                            }
                            if (!string.IsNullOrEmpty(_topart))
                            {
                                upDr["topart"] = _topart;
                            }
                            upDr["status"]     = 0;
                            upDr["updateuser"] = SystemUser.CurrentUser.UserID;
                            upDr["updatetime"] = DateTime.Now;
                            if (!string.IsNullOrEmpty(_statisticstype))
                            {
                                upDr["statisticstype"] = Convert.ToInt32(_statisticstype);
                            }
                            upDr["vehicletyperequirement"]   = _vehicletyperequirement;
                            upDr["vehiclelengthrequirement"] = _vehiclelengthrequirement;
                            dt.Rows.Add(upDr);
                            dbc.UpdateTable(dt, dtt);
                        }
                        else
                        {
                            var id   = Guid.NewGuid().ToString();
                            var dt   = dbc.GetEmptyDataTable("tb_b_pricemodel");
                            var inDr = dt.NewRow();
                            inDr["id"]            = id;
                            inDr["goodsname"]     = goodsname;
                            inDr["goodstypeid"]   = goodstypeid;
                            inDr["goodsid"]       = goodsid;
                            inDr["fromroutecode"] = _fromroutecode;
                            inDr["fromroutename"] = _fromroutename;
                            inDr["toroutecode"]   = _toroutecode;
                            inDr["toroutename"]   = _toroutename;
                            inDr["price"]         = !string.IsNullOrEmpty(_price) ? Convert.ToDecimal(_price) : 0m;
                            inDr["pickprice"]     = !string.IsNullOrEmpty(_pickprice) ? Convert.ToDecimal(_pickprice) : 0m;
                            inDr["deliverprice"]  = !string.IsNullOrEmpty(_deliverprice) ? Convert.ToDecimal(_deliverprice) : 0m;
                            if (!string.IsNullOrEmpty(_frompart))
                            {
                                inDr["frompart"] = _frompart;
                            }
                            if (!string.IsNullOrEmpty(_topart))
                            {
                                inDr["topart"] = _topart;
                            }
                            inDr["status"]     = 0;
                            inDr["adduser"]    = SystemUser.CurrentUser.UserID;
                            inDr["addtime"]    = DateTime.Now;
                            inDr["updateuser"] = SystemUser.CurrentUser.UserID;
                            inDr["updatetime"] = DateTime.Now;
                            if (!string.IsNullOrEmpty(_statisticstype))
                            {
                                inDr["statisticstype"] = Convert.ToInt32(_statisticstype);
                            }
                            inDr["vehicletyperequirement"]   = _vehicletyperequirement;
                            inDr["vehiclelengthrequirement"] = _vehiclelengthrequirement;

                            dt.Rows.Add(inDr);
                            dbc.InsertTable(dt);
                        }
                        #endregion
                    }
                }

                sql = @"select id,CASE statisticstype WHEN 1 THEN '零担' WHEN 2 THEN '整车' ELSE '' END transporttype,
                        fromroutecode,fromroutename,toroutecode,toroutename,price,pickprice,deliverprice,frompart,topart
                        from tb_b_pricemodel 
                        where goodsid=" + dbc.ToSqlValue(goodsid) + " and status=0 order by updatetime desc";
                DataTable retDt = dbc.ExecuteDataTable(sql);

                dbc.CommitTransaction();
                return(new { dt = retDt, str = str });
            }
            catch (Exception ex)
            {
                dbc.RoolbackTransaction();
                throw ex;
            }
        }
    }
コード例 #4
0
ファイル: JFSQMag.cs プロジェクト: freedomxuli/chbappweb
    public object JFSQ(string sqId, int issq)
    {
        using (DBConnection dbc = new DBConnection())
        {
            dbc.BeginTransaction();
            try
            {
                if (issq == 1)
                {
                    string    str = "select * from tb_b_jfsq where issq=0 and sqId=" + dbc.ToSqlValue(sqId);
                    DataTable sdt = dbc.ExecuteDataTable(str);

                    var userId = "";
                    if (sdt.Rows.Count > 0)
                    {
                        userId = sdt.Rows[0]["UserID"].ToString();
                        decimal points = 0;
                        str = "select * from tb_b_user where UserID=" + dbc.ToSqlValue(userId);
                        DataTable pdt = dbc.ExecuteDataTable(str);
                        if (pdt.Rows.Count > 0)
                        {
                            points += Convert.ToDecimal(pdt.Rows[0]["Points"].ToString());
                        }

                        points = points + Convert.ToDecimal(sdt.Rows[0]["sqjf"].ToString());

                        var udt  = dbc.GetEmptyDataTable("tb_b_user");
                        var udtt = new SmartFramework4v2.Data.DataTableTracker(udt);
                        var usr  = udt.NewRow();
                        usr["UserID"] = new Guid(userId);
                        usr["Points"] = points;
                        udt.Rows.Add(usr);
                        dbc.UpdateTable(udt, udtt);

                        var dt  = dbc.GetEmptyDataTable("tb_b_jfsq");
                        var dtt = new SmartFramework4v2.Data.DataTableTracker(dt);
                        var sr  = dt.NewRow();
                        sr["sqId"]     = new Guid(sqId);
                        sr["issq"]     = issq;
                        sr["shtime"]   = DateTime.Now;
                        sr["shuserId"] = SystemUser.CurrentUser.UserID;
                        dt.Rows.Add(sr);
                        dbc.UpdateTable(dt, dtt);
                    }
                }
                else if (issq == 2)
                {
                    string    str = "select * from tb_b_jfsq where issq=0 and sqId=" + dbc.ToSqlValue(sqId);
                    DataTable sdt = dbc.ExecuteDataTable(str);

                    if (sdt.Rows.Count > 0)
                    {
                        var dt  = dbc.GetEmptyDataTable("tb_b_jfsq");
                        var dtt = new SmartFramework4v2.Data.DataTableTracker(dt);
                        var sr  = dt.NewRow();
                        sr["sqId"]     = new Guid(sqId);
                        sr["issq"]     = issq;
                        sr["shtime"]   = DateTime.Now;
                        sr["shuserId"] = SystemUser.CurrentUser.UserID;
                        dt.Rows.Add(sr);
                        dbc.UpdateTable(dt, dtt);
                    }
                }
                dbc.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                dbc.RoolbackTransaction();
                throw ex;
            }
        }
    }
コード例 #5
0
ファイル: JFSQMag.cs プロジェクト: freedomxuli/chbappweb
    public bool SaveKCYFQ(JSReader jsr)
    {
        using (DBConnection dbc = new DBConnection())
        {
            dbc.BeginTransaction();
            try
            {
                var time = DateTime.Now;

                var kfsj = DateTime.Now.ToString();

                var       UserID = jsr["UserID"].ToString();
                string    str    = "select * from tb_b_user where UserID=" + dbc.ToSqlValue(UserID);
                DataTable pdt    = dbc.ExecuteDataTable(str);

                if (pdt.Rows.Count > 0)
                {
                    if (Convert.ToDecimal(pdt.Rows[0]["Points"].ToString()) - Convert.ToDecimal(jsr["points"].ToString()) < 0)
                    {
                        throw new Exception("扣除的运费券不得超过其所有运费券!");
                    }
                    else
                    {
                        var dt = dbc.GetEmptyDataTable("tb_b_jfsq");
                        var sr = dt.NewRow();
                        sr["sqId"]     = Guid.NewGuid().ToString();
                        sr["userId"]   = new Guid(UserID);
                        sr["sqrq"]     = DateTime.Now;
                        sr["memo"]     = jsr["memo"];
                        sr["sqjf"]     = -Convert.ToDecimal(jsr["points"].ToString());
                        sr["issq"]     = 1;
                        sr["shtime"]   = DateTime.Now;
                        sr["shuserId"] = SystemUser.CurrentUser.UserID;
                        dt.Rows.Add(sr);
                        dbc.InsertTable(dt);

                        var cdt = dbc.GetEmptyDataTable("tb_b_cancelpoints");
                        var csr = cdt.NewRow();
                        csr["cancelid"] = Guid.NewGuid().ToString();
                        csr["userid"]   = new Guid(UserID);
                        csr["memo"]     = jsr["memo"];
                        csr["points"]   = Convert.ToDecimal(jsr["points"].ToString());
                        csr["addtime"]  = DateTime.Now;
                        csr["adduser"]  = SystemUser.CurrentUser.UserID;
                        csr["status"]   = 0;
                        cdt.Rows.Add(csr);
                        dbc.InsertTable(cdt);

                        var udt  = dbc.GetEmptyDataTable("tb_b_user");
                        var udtt = new SmartFramework4v2.Data.DataTableTracker(udt);
                        var usr  = udt.NewRow();
                        usr["UserID"] = new Guid(UserID);
                        usr["Points"] = Convert.ToDecimal(pdt.Rows[0]["Points"].ToString()) - Convert.ToDecimal(jsr["points"].ToString());
                        udt.Rows.Add(usr);
                        dbc.UpdateTable(udt, udtt);
                    }
                }
                dbc.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                dbc.RoolbackTransaction();
                throw ex;
            }
        }
    }
コード例 #6
0
ファイル: ZXSHMag.cs プロジェクト: freedomxuli/chbappweb
    public object ZFQSH(string SaleRecordID, int issh, string thyj)
    {
        using (DBConnection dbc = new DBConnection())
        {
            dbc.BeginTransaction();
            try
            {
                var       time   = DateTime.Now;
                var       userid = "";
                string    str    = "select * from tb_b_salerecord where (SaleRecordVerifyType=0 or SaleRecordVerifyType is null) and SaleRecordID=" + dbc.ToSqlValue(SaleRecordID);
                DataTable sdt    = dbc.ExecuteDataTable(str);

                if (sdt.Rows.Count > 0)
                {
                    var dt  = dbc.GetEmptyDataTable("tb_b_salerecord");
                    var dtt = new SmartFramework4v2.Data.DataTableTracker(dt);
                    var sr  = dt.NewRow();
                    sr["SaleRecordID"]         = new Guid(SaleRecordID);
                    sr["SaleRecordVerifyType"] = issh;
                    sr["SaleRecordVerifyTime"] = time;
                    dt.Rows.Add(sr);
                    dbc.UpdateTable(dt, dtt);


                    string    str1 = "select * from tb_b_plattosale where (SaleRecordVerifyType=0 or SaleRecordVerifyType is null) and SaleRecordID=" + dbc.ToSqlValue(SaleRecordID);
                    DataTable sdt1 = dbc.ExecuteDataTable(str1);

                    if (sdt1.Rows.Count > 0)
                    {
                        var dt1  = dbc.GetEmptyDataTable("tb_b_plattosale");
                        var dtt1 = new SmartFramework4v2.Data.DataTableTracker(dt1);
                        var sr1  = dt1.NewRow();
                        sr1["PlatToSaleId"]         = sdt1.Rows[0]["PlatToSaleId"];
                        sr1["SaleRecordVerifyType"] = issh;
                        sr1["SaleRecordVerifyTime"] = time;
                        sr1["SaleRecordTime"]       = sdt.Rows[0]["SaleRecordTime"];
                        dt1.Rows.Add(sr1);
                        dbc.UpdateTable(dt1, dtt1);

                        userid = sdt1.Rows[0]["UserID"].ToString();


                        string    str2 = "select * from tb_b_user where userid=" + dbc.ToSqlValue(userid);
                        DataTable udt  = dbc.ExecuteDataTable(str2);
                        if (udt.Rows.Count > 0)
                        {
                            var username = udt.Rows[0]["UserName"];

                            if (issh == 1)
                            {
                                string _url      = ServiceURL + "sendSms/releasePass";
                                string jsonParam = new JavaScriptSerializer().Serialize(new
                                {
                                    username = udt.Rows[0]["UserName"],
                                    userxm   = udt.Rows[0]["UserXM"]
                                });
                                var request = (HttpWebRequest)WebRequest.Create(_url);
                                request.Method      = "POST";
                                request.ContentType = "application/json;charset=UTF-8";
                                var byteData = Encoding.UTF8.GetBytes(jsonParam);
                                var length   = byteData.Length;
                                request.ContentLength = length;
                                var writer = request.GetRequestStream();
                                writer.Write(byteData, 0, length);
                                writer.Close();
                            }
                            else
                            {
                                string _url      = ServiceURL + "sendSms/releaseReject";
                                string jsonParam = new JavaScriptSerializer().Serialize(new
                                {
                                    username = udt.Rows[0]["UserName"],
                                    userxm   = udt.Rows[0]["UserXM"],
                                    memo     = thyj
                                });
                                var request = (HttpWebRequest)WebRequest.Create(_url);
                                request.Method      = "POST";
                                request.ContentType = "application/json;charset=UTF-8";
                                var byteData = Encoding.UTF8.GetBytes(jsonParam);
                                var length   = byteData.Length;
                                request.ContentLength = length;
                                var writer = request.GetRequestStream();
                                writer.Write(byteData, 0, length);
                                writer.Close();
                            }
                        }
                    }
                }
                dbc.CommitTransaction();
                try
                {
                    KFGMMag.WebServiceApp(System.Configuration.ConfigurationManager.AppSettings["ServiceURL"].ToString(), "pcReleaseNotify", "userid=" + userid);
                }
                catch (Exception ex)
                {
                    return(true);
                }

                return(true);
            }
            catch (Exception ex)
            {
                dbc.RoolbackTransaction();
                throw ex;
            }
        }
    }
コード例 #7
0
ファイル: CarMag.cs プロジェクト: freedomxuli/chbappweb
    public bool SaveCar(JSReader jsr)
    {
        if (jsr["caruser"].IsNull || jsr["caruser"].IsEmpty)
        {
            throw new Exception("车主不能为空");
        }

        using (DBConnection dbc = new DBConnection())
        {
            dbc.BeginTransaction();
            try
            {
                if (jsr["id"].ToString() != "")
                {
                    var       userName = jsr["caruser"].ToString();
                    var       cz       = "";
                    DataTable czdt     = dbc.ExecuteDataTable("select * from tb_b_user where userName="******"车主未绑定宝付账号!");
                        // }
                        // else
                        //  {
                        cz = czdt.Rows[0]["UserID"].ToString();
                        // }
                    }
                    else
                    {
                        throw new Exception("车主账号不存在!");
                    }
                    var sj = "";
                    if (!jsr["drivername"].IsNull && !jsr["drivername"].IsEmpty)
                    {
                        DataTable sjdt = dbc.ExecuteDataTable("select * from tb_b_user where (clientkind = 1 or clientkind = 2) and userName="******"drivername"].ToString()));
                        if (sjdt.Rows.Count > 0)
                        {
                            sj = sjdt.Rows[0]["UserID"].ToString();
                        }
                        else
                        {
                            throw new Exception("司机账号不存在!");
                        }
                    }

                    var dt  = dbc.GetEmptyDataTable("tb_b_car");
                    var dtt = new SmartFramework4v2.Data.DataTableTracker(dt);
                    var dr  = dt.NewRow();

                    dr["id"]           = new Guid(jsr["id"].ToString());
                    dr["mirrornumber"] = jsr["mirrornumber"].ToString();
                    dr["linkedunit"]   = jsr["linkedunit"].ToString();
                    if (!string.IsNullOrEmpty(cz))
                    {
                        dr["userid"]  = cz;
                        dr["caruser"] = userName;
                    }
                    dr["driverxm"]   = jsr["driverxm"].ToString();
                    dr["drivername"] = jsr["drivername"].ToString();
                    dr["drivermemo"] = jsr["drivermemo"].ToString();
                    dr["idcard"]     = jsr["idcard"].ToString();
                    dr["roadnumber"] = jsr["roadnumber"].ToString();
                    if (!string.IsNullOrEmpty(sj))
                    {
                        dr["driverid"] = sj;
                    }
                    dr["updateuser"] = SystemUser.CurrentUser.UserID;
                    dr["updatetime"] = DateTime.Now;
                    dt.Rows.Add(dr);
                    dbc.UpdateTable(dt, dtt);
                }
                else
                {
                    throw new Exception("该车辆不存在!");
                }
                dbc.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                dbc.RoolbackTransaction();
                throw ex;
            }
        }
    }
コード例 #8
0
    public bool SaveUser(JSReader jsr)
    {
        using (DBConnection dbc = new DBConnection())
        {
            dbc.BeginTransaction();
            try
            {
                var time = DateTime.Now;

                var kfsj = DateTime.Now.ToString();

                if (jsr["kfsj_rq"] != null && jsr["kfsj_rq"].ToString() != "")
                {
                    kfsj = Convert.ToDateTime(jsr["kfsj_rq"].ToString()).ToString("yyyy-MM-dd");

                    if (jsr["kfsj_hour"] != null && jsr["kfsj_hour"].ToString() != "")
                    {
                        kfsj += " " + jsr["kfsj_hour"].ToString() + ":00:00";
                    }
                }
                var       PlatPointId = jsr["PlatPointId"].ToString();
                string    str         = "select * from tb_b_platpoints where PlatPointId=" + dbc.ToSqlValue(PlatPointId);
                DataTable pdt         = dbc.ExecuteDataTable(str);

                if (pdt.Rows.Count > 0)
                {
                    if (Convert.ToDecimal(pdt.Rows[0]["Points"].ToString()) - Convert.ToDecimal(jsr["points"].ToString()) < 0)
                    {
                        throw new Exception("开放购买的运费券不得超过其所有运费券!");
                    }
                    else
                    {
                        var userid = pdt.Rows[0]["UserID"].ToString();
                        str = "select * from tb_b_user where UserID='" + userid + "'";
                        DataTable udt = dbc.ExecuteDataTable(str);

                        var wlmc = "";
                        if (udt.Rows.Count > 0)
                        {
                            wlmc = udt.Rows[0]["UserXM"].ToString();
                        }

                        var SaleRecordID = Guid.NewGuid().ToString();

                        var logdt = dbc.GetEmptyDataTable("tb_b_salerecord");
                        var logdr = logdt.NewRow();
                        logdr["SaleRecordID"]         = SaleRecordID;
                        logdr["SaleRecordCode"]       = GetRandom();
                        logdr["SaleRecordUserID"]     = userid;
                        logdr["SaleRecordUserXM"]     = wlmc;
                        logdr["SaleRecordTime"]       = kfsj;
                        logdr["SaleRecordPoints"]     = Convert.ToDecimal(jsr["points"].ToString());
                        logdr["SaleRecordLX"]         = 0;
                        logdr["Status"]               = 0;
                        logdr["adduser"]              = SystemUser.CurrentUser.UserID;
                        logdr["addtime"]              = time;
                        logdr["updateuser"]           = SystemUser.CurrentUser.UserID;
                        logdr["updatetime"]           = time;
                        logdr["SaleRecordBelongID"]   = "6E72B59D-BEC6-4835-A66F-8BC70BD82FE9";
                        logdr["ValidHour"]            = Convert.ToDecimal(jsr["validHour"].ToString());
                        logdr["SaleRecordDiscount"]   = Convert.ToDecimal(jsr["discount"].ToString());
                        logdr["SaleRecordVerifyType"] = 1;
                        logdr["SaleRecordVerifyTime"] = kfsj;
                        logdt.Rows.Add(logdr);
                        dbc.InsertTable(logdt);


                        var saledt = dbc.GetEmptyDataTable("tb_b_plattosale");
                        DataTableTracker saledtt = new DataTableTracker(saledt);
                        if (string.IsNullOrEmpty(jsr["PlatToSaleId"].ToString()))
                        {
                            var saledr = saledt.NewRow();
                            saledr["PlatToSaleId"]         = Guid.NewGuid().ToString();
                            saledr["UserID"]               = userid;
                            saledr["points"]               = Convert.ToDecimal(jsr["points"].ToString());
                            saledr["addtime"]              = DateTime.Now;
                            saledr["status"]               = 0;
                            saledr["discount"]             = Convert.ToDecimal(jsr["discount"].ToString());
                            saledr["discountmemo"]         = jsr["discountmemo"].ToString();
                            saledr["pointkind"]            = 0;
                            saledr["SaleRecordID"]         = SaleRecordID;
                            saledr["belongID"]             = "6E72B59D-BEC6-4835-A66F-8BC70BD82FE9";
                            saledr["validHour"]            = Convert.ToDecimal(jsr["validHour"].ToString());
                            saledr["SaleRecordTime"]       = kfsj;
                            saledr["SaleRecordVerifyType"] = 1;
                            saledr["SaleRecordVerifyTime"] = kfsj;
                            saledt.Rows.Add(saledr);
                            dbc.InsertTable(saledt);
                        }
                        else
                        {
                            str = "select points from tb_b_plattosale where PlatToSaleId = " + dbc.ToSqlValue(jsr["PlatToSaleId"].ToString());
                            decimal sale_new_points = Convert.ToDecimal(dbc.ExecuteScalar(str));

                            if (sale_new_points > 0)
                            {
                                throw new Exception("线上还有剩余" + sale_new_points + "运费券没卖完!不能开放!");
                            }
                            else
                            {
                                var saledr = saledt.NewRow();
                                saledr["PlatToSaleId"]         = jsr["PlatToSaleId"].ToString();
                                saledr["points"]               = Convert.ToDecimal(jsr["points"].ToString());
                                saledr["addtime"]              = DateTime.Now;
                                saledr["status"]               = 0;
                                saledr["discount"]             = Convert.ToDecimal(jsr["discount"].ToString());
                                saledr["discountmemo"]         = jsr["discountmemo"].ToString();
                                saledr["pointkind"]            = 0;
                                saledr["SaleRecordID"]         = SaleRecordID;
                                saledr["belongID"]             = "6E72B59D-BEC6-4835-A66F-8BC70BD82FE9";
                                saledr["validHour"]            = Convert.ToDecimal(jsr["validHour"].ToString());
                                saledr["SaleRecordTime"]       = kfsj;
                                saledr["SaleRecordVerifyType"] = 1;
                                saledr["SaleRecordVerifyTime"] = kfsj;
                                saledt.Rows.Add(saledr);
                                dbc.UpdateTable(saledt, saledtt);
                            }
                        }

                        var dt  = dbc.GetEmptyDataTable("tb_b_platpoints");
                        var dtt = new SmartFramework4v2.Data.DataTableTracker(dt);
                        var dr  = dt.NewRow();
                        dr["PlatPointId"] = PlatPointId;
                        var point = Convert.ToDecimal(pdt.Rows[0]["Points"].ToString()) - Convert.ToDecimal(jsr["points"].ToString());
                        dr["Points"] = point;
                        dt.Rows.Add(dr);
                        dbc.UpdateTable(dt, dtt);

                        string    sql  = @"select distinct b.UserID,b.OpenID from tb_b_user_gz a left join tb_b_user b on a.UserId=b.UserID
                        where a.GZUserID=" + dbc.ToSqlValue(userid) + " and b.OpenID is not null";
                        DataTable gzdt = dbc.ExecuteDataTable(sql);

                        if (gzdt.Rows.Count > 0)
                        {
                            for (int i = 0; i < gzdt.Rows.Count; i++)
                            {
                                try
                                {
                                    WebServiceApp(System.Configuration.ConfigurationManager.AppSettings["ServiceURL"].ToString(), "pcReleaseNotify", "userid=" + userid);
                                    //new Handler().SendWeText(gzdt.Rows[i]["OpenID"].ToString(), "您关注的" + wlmc + "已开放运费券,赶紧抢购哦,手慢无!");
                                }
                                catch (Exception ex)
                                {
                                    throw ex;
                                }
                            }
                        }
                    }
                }
                dbc.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                dbc.RoolbackTransaction();
                throw ex;
            }
        }
    }