示例#1
0
 public void Update(Core.Domain.Building model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     IRepository = new BuildingRepositary();
     IRepository.Update(model);
 }
        public void Update(Core.Domain.Building model)
        {
            db = new SqlConnection(ConfigurationManager.ConnectionStrings["cnConsumption"].ConnectionString);
            string sql = " Update tblItem Set CategoryID=@CategoryID,BrandID=@BrandID,ItemCode=@ItemCode,Name=@Name,Unit=@Unit Where id=@ID";

            db.Execute(sql, new
            {
                model.ID
            });

            db.Close();
        }
        public int InsertBuilding(Core.Domain.Building model, ref string ErrorMsg)
        {
            int ID = 0;

            db = new SqlConnection(ConfigurationManager.ConnectionStrings["cnConsumption"].ConnectionString);
            string sql = " INSERT INTO tblBuilding(BuildingNo,BuildingName,TankID) " +
                         " VALUES (@BuildingNo,@BuildingName,@TankID)" +
                         " Select Cast(SCOPE_IDENTITY() AS int)";

            try
            {
                ID = db.Query <int>(sql, new
                {
                    model.BuildingNo,
                    model.BuildingName,
                    model.TankID
                }).SingleOrDefault();
            }
            catch (Exception e)
            {
                if (e.Message.IndexOf("IX_tblItem-Name") > 0)
                {
                    ErrorMsg = "Item Already Exist....";
                }
                else
                {
                    ErrorMsg = e.Message;
                }

                db.Close();
                return(0);
            }
            model.ID = ID;
            db.Close();

            return(ID);
        }
示例#4
0
 public int InsertBuilding(Core.Domain.Building model, ref string ErrorMsg)
 {
     IRepository = new BuildingRepositary();
     return(IRepository.InsertBuilding(model, ref ErrorMsg));
 }