Пример #1
0
        public static bool AddUseTrans(tbl_UserTransportation model)
        {
            string sql = @"INSERT INTO  Gungnir.[dbo].[tbl_UserTransportation]
           ([Rank]
           ,[TransMoney]
           ,[Discount]
           ,[SaleMoney])
     VALUES
           (@Rank
           ,@TransMoney
           ,@Discount
           ,@SaleMoney)";

            var conn = ConfigurationManager.ConnectionStrings["Gungnir"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            using (var db = new SqlDbHelper(conn))
            {
                SqlCommand cmd = new SqlCommand(sql);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@Rank", model.Rank);
                cmd.Parameters.AddWithValue("@TransMoney", model.TransMoney);
                cmd.Parameters.AddWithValue("@Discount", model.Discount);
                cmd.Parameters.AddWithValue("@SaleMoney", model.SaleMoney);
                return(db.ExecuteNonQuery(cmd) > 0);
            }
        }
        public static List <tbl_UserTransportation> GetUseTransMoney()
        {
            List <tbl_UserTransportation> list = new List <tbl_UserTransportation>();
            DataTable dt = DALUserPermission.GetUseTransMoney();

            if (dt == null || dt.Rows.Count <= 0)
            {
                tbl_UserTransportation model1 = new tbl_UserTransportation();
                model1.Rank = 1;
                tbl_UserTransportation model2 = new tbl_UserTransportation();
                model2.Rank = 2;
                tbl_UserTransportation model3 = new tbl_UserTransportation();
                model3.Rank = 3;
                tbl_UserTransportation model4 = new tbl_UserTransportation();
                model4.Rank = 4;
                list.Add(model1);
                list.Add(model2);
                list.Add(model3);
                list.Add(model4);
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    tbl_UserTransportation item = new tbl_UserTransportation(dr);
                    list.Add(item);
                }
            }
            return(list);
        }
Пример #3
0
        public static bool UpdateTrans(tbl_UserTransportation model)
        {
            string sql  = @" update  Gungnir.[dbo].[tbl_UserTransportation] set TransMoney=@TransMoney,Discount=@Discount,SaleMoney=@SaleMoney where [Rank]=@Rank ";
            var    conn = ConfigurationManager.ConnectionStrings["Gungnir"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            using (var db = new SqlDbHelper(conn))
            {
                SqlCommand cmd = new SqlCommand(sql);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@Rank", model.Rank);
                cmd.Parameters.AddWithValue("@TransMoney", model.TransMoney);
                cmd.Parameters.AddWithValue("@Discount", model.Discount);
                cmd.Parameters.AddWithValue("@SaleMoney", model.SaleMoney);
                return(db.ExecuteNonQuery(cmd) > 0);
            }
        }