Example #1
0
        public static void AddBuyRequest(AssetBuyInfoVM buy)
        {
            var now   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            var sql   = @"insert into AssetBuyInfo (EngName, ChName, UnitPrice,
                    Brand, Model, OriginCountry, Picture, Purpose, Functions,
                    WorkPrinciple, CorporatePurposes, Status, CreateAt, UpdateAt) 
                    values (@EngName, @ChName, @UnitPrice,
                    @Brand, @Model, @OriginCountry, @Picture, @Purpose, @Functions,
                    @WorkPrinciple, @CorporatePurposes, @Status, @CreateAt, @UpdateAt)";
            var param = new Dictionary <string, string>();

            param.Add("@EngName", buy.EngName);
            param.Add("@ChName", buy.ChName);
            param.Add("@UnitPrice", buy.UnitPrice);
            param.Add("@Brand", buy.Brand);
            param.Add("@Model", buy.Model);
            param.Add("@OriginCountry", buy.OriginCountry);
            param.Add("@Picture", buy.Picture);
            param.Add("@Purpose", buy.Purpose);
            param.Add("@Functions", buy.Functions);
            param.Add("@WorkPrinciple", buy.WorkPrinciple);
            param.Add("@CorporatePurposes", buy.CorporatePurposes);
            param.Add("@Status", BuyStatus.Request.ToString());
            param.Add("@CreateAt", now);
            param.Add("@UpdateAt", now);

            DBUtility.ExeLocalSqlNoRes(sql, param);
        }
Example #2
0
        public static List <AssetBuyInfoVM> GetAssetBuyInfo(string key = "", string id = "")
        {
            var sql   = @"select abi.* from AssetBuyInfo as abi where Status != @Status ";
            var param = new Dictionary <string, string>();

            param.Add("@Status", BuyStatus.Invalid.ToString());
            if (!string.IsNullOrEmpty(id))
            {
                sql += " and abi.ID = @ID ";
                param.Add("@ID", id);
            }
            if (!string.IsNullOrEmpty(key))
            {
                sql += " and abi.EngName like @key or abi.ChName like @key ";
                param.Add("@key", "%" + key + "%");
            }
            sql += " order by abi.Status, abi.UpdateAt Desc";
            var dbret = DBUtility.ExeLocalSqlWithRes(sql, param);
            var res   = new List <AssetBuyInfoVM>();

            if (dbret.Count > 0)
            {
                foreach (var item in dbret)
                {
                    var tmp = new AssetBuyInfoVM();
                    tmp.ID                = Convert.ToString(item[0]);
                    tmp.EngName           = Convert.ToString(item[1]);
                    tmp.ChName            = Convert.ToString(item[2]);
                    tmp.UnitPrice         = Convert.ToString(item[3]);
                    tmp.Brand             = Convert.ToString(item[4]);
                    tmp.Model             = Convert.ToString(item[5]);
                    tmp.OriginCountry     = Convert.ToString(item[6]);
                    tmp.Picture           = Convert.ToString(item[7]);
                    tmp.Purpose           = Convert.ToString(item[8]);
                    tmp.Functions         = Convert.ToString(item[9]);
                    tmp.WorkPrinciple     = Convert.ToString(item[10]);
                    tmp.CorporatePurposes = Convert.ToString(item[11]);
                    tmp.Status            = Convert.ToString(item[12]);
                    tmp.CreateAt          = Convert.ToString(item[13]);
                    tmp.UpdateAt          = Convert.ToString(item[14]);
                    res.Add(tmp);
                }
            }

            return(res);
        }
Example #3
0
        public static void UpdateBuyRequest(AssetBuyInfoVM buy)
        {
            var sql   = "update AssetBuyInfo set ";
            var param = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(buy.EngName))
            {
                sql += " EngName = @EngName, ";
                param.Add("@EngName", buy.EngName);
            }
            if (!string.IsNullOrEmpty(buy.ChName))
            {
                sql += " ChName = @ChName, ";
                param.Add("@ChName", buy.ChName);
            }
            if (!string.IsNullOrEmpty(buy.UnitPrice))
            {
                sql += " UnitPrice = @UnitPrice, ";
                param.Add("@UnitPrice", buy.UnitPrice);
            }
            if (!string.IsNullOrEmpty(buy.Brand))
            {
                sql += " Brand = @Brand, ";
                param.Add("@Brand", buy.Brand);
            }
            if (!string.IsNullOrEmpty(buy.Model))
            {
                sql += " Model = @Model, ";
                param.Add("@Model", buy.Model);
            }
            if (!string.IsNullOrEmpty(buy.OriginCountry))
            {
                sql += " OriginCountry = @OriginCountry, ";
                param.Add("@OriginCountry", buy.OriginCountry);
            }
            if (!string.IsNullOrEmpty(buy.Picture))
            {
                sql += " Picture = @Picture, ";
                param.Add("@Picture", buy.Picture);
            }
            if (!string.IsNullOrEmpty(buy.Purpose))
            {
                sql += " Purpose = @Purpose, ";
                param.Add("@Purpose", buy.Purpose);
            }
            if (!string.IsNullOrEmpty(buy.Functions))
            {
                sql += " Functions = @Functions, ";
                param.Add("@Functions", buy.Functions);
            }
            if (!string.IsNullOrEmpty(buy.WorkPrinciple))
            {
                sql += " WorkPrinciple = @WorkPrinciple, ";
                param.Add("@WorkPrinciple", buy.WorkPrinciple);
            }
            if (!string.IsNullOrEmpty(buy.CorporatePurposes))
            {
                sql += " CorporatePurposes = @CorporatePurposes, ";
                param.Add("@CorporatePurposes", buy.CorporatePurposes);
            }
            if (!string.IsNullOrEmpty(buy.Status))
            {
                sql += " Status = @Status, ";
                param.Add("@Status", buy.Status);
            }

            sql += " UpdateAt = @UpdateAt where ID = @ID";
            param.Add("@UpdateAt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            param.Add("@ID", buy.ID);

            DBUtility.ExeLocalSqlNoRes(sql, param);
        }