示例#1
0
        public string ChgShipper(ShipperAM oShipper)
        {
            string rc = "";

            using (var scope = new TransactionScope())
            {
                try
                {
                    string ConnStr = GetConnStr();
                    using (SqlConnection Conn = new SqlConnection(ConnStr))
                    {
                        Conn.Open();
                        string SqlTxt = "";
                        SqlTxt += " UPDATE [dbo].[Shippers] ";
                        SqlTxt += " SET CompanyName = @CompanyName ";
                        SqlTxt += " 	, Phone = @Phone ";
                        SqlTxt += " WHERE ShipperID = @ShipperID ";
                        SqlTxt += "  ";
                        Conn.Execute(SqlTxt, oShipper);
                        rc = "Success";
                    }
                    scope.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            return(rc);
        }
示例#2
0
        public string InsertShipper(ShipperAM oShipper)
        {
            string rc = "";

            using (var scope = new TransactionScope())
            {
                try
                {
                    string ConnStr = GetConnStr();
                    using (SqlConnection Conn = new SqlConnection(ConnStr))
                    {
                        Conn.Open();
                        string SqlTxt = "";
                        SqlTxt += " INSERT INTO [dbo].[Shippers] ";
                        SqlTxt += " 	(CompanyName, Phone) ";
                        SqlTxt += " VALUES (@CompanyName, @Phone) ";
                        SqlTxt += "  ";
                        Conn.Execute(SqlTxt, oShipper);
                        rc = "Success";
                    }
                    scope.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            return(rc);
        }
示例#3
0
        public ShipperAM getShipper(int ShipperID)
        {
            ShipperAM oShipper = new ShipperAM();

            try
            {
                string ConnStr = GetConnStr();
                using (SqlConnection Conn = new SqlConnection(ConnStr))
                {
                    Conn.Open();
                    string SqlTxt = "";
                    SqlTxt += " SELECT * ";
                    SqlTxt += " FROM [dbo].[Shippers] (NOLOCK) ";
                    SqlTxt += " WHERE ShipperID = @ShipperID ";
                    SqlTxt += "  ";

                    oShipper = Conn.Query <ShipperAM>(SqlTxt, new { ShipperID = ShipperID }).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(oShipper);
        }
        public ShipperAM getShipper(int ShipperID = 0)
        {
            ShipperAM  oShipper = new ShipperAM();
            ShipperDao dao      = new ShipperDao();

            try
            {
                oShipper = dao.getShipper(ShipperID);
            }
            catch (Exception ex)
            {
                ErrMsgInfo oErr = new ErrMsgInfo();
                oErr.ex = ex;
                HttpResponseMessage RepMsg = oErr.RepMsg;
                throw new HttpResponseException(RepMsg);
            }
            return(oShipper);
        }
        public JsonRltInfo UpdateItem([FromBody] ShipperAM oShipper)
        {
            JsonRltInfo oRlt = new JsonRltInfo();
            ShipperDao  dao  = new ShipperDao();

            try
            {
                string rc = dao.ChgShipper(oShipper);
                if (rc == "Success")
                {
                    oRlt.rltCode = 0;
                    oRlt.rltMsg  = "更新成功";
                }
            }
            catch (Exception ex)
            {
                oRlt.rltCode = 417;
                oRlt.rltMsg  = ex.Message;
            }
            return(oRlt);
        }