private void Validate(Model.ProductMouldSize model)
 {
     if (string.IsNullOrEmpty(model.ProductSizeId))
     {
         throw new Helper.InvalidValueException(Model.ProductMouldSize.PRO_ProductSizeId);
     }
 }
        /// <summary>
        /// Insert a ProductMouldSize.
        /// </summary>
        public void Insert(Model.ProductMouldSize productMouldSize)
        {
            //
            // todo:add other logic here
            //
            Validate(productMouldSize);
            productMouldSize.InsertTime = DateTime.Now;
            productMouldSize.UpdateTime = DateTime.Now;
            accessor.Insert(productMouldSize);

            //上传附件
            if (!string.IsNullOrEmpty(productMouldSize.Upload))
            {
                string sfdir = this.ServerSavePath + "\\" + productMouldSize.ProductMouldSizeId;
                try
                {
                    System.IO.Directory.CreateDirectory(sfdir);
                }
                catch (Exception ex)
                { throw new Helper.MessageValueException(ex.Message); }
                foreach (string fn in productMouldSize.Upload.Split('|'))
                {
                    if (!fn.Contains(this.ServerSavePath))
                    {
                        System.IO.File.Copy(fn, sfdir + "\\" + fn.Substring(fn.LastIndexOf("\\") + 1), true);
                    }
                }
            }
        }
示例#3
0
        protected override void AddNew()
        {
            this._productMouldSize = new Book.Model.ProductMouldSize();
            this._productMouldSize.ProductMouldSizeId = Guid.NewGuid().ToString();
            this._productMouldSize.ProductDate        = DateTime.Now;

            this.action = "insert";
        }
示例#4
0
 protected override void MovePrev()
 {
     Model.ProductMouldSize model = this._manager.GetPrev(this._productMouldSize);
     if (model == null)
     {
         throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows);
     }
     this._productMouldSize = model;
 }
示例#5
0
        //搜索
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ProductMouldSizeList f = new ProductMouldSizeList();

            if (f.ShowDialog(this) == DialogResult.OK)
            {
                Model.ProductMouldSize model = f.SelectItem as Model.ProductMouldSize;
                if (model != null)
                {
                    this._productMouldSize = model;
                    this.Refresh();
                }
            }
        }
示例#6
0
 protected override void Delete()
 {
     if (this._productMouldSize == null)
     {
         return;
     }
     if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
     {
         return;
     }
     this._manager.Delete(this._productMouldSize.ProductMouldSizeId);
     this._productMouldSize = this._manager.GetNext(this._productMouldSize);
     if (this._productMouldSize == null)
     {
         this._productMouldSize = this._manager.GetLast();
     }
 }
示例#7
0
 public Model.ProductMouldSize GetPrev(Model.ProductMouldSize e)
 {
     return(sqlmapper.QueryForObject <Model.ProductMouldSize>("ProductMouldSize.get_prev", e));
 }
示例#8
0
 public Model.ProductMouldSize GetNext(Model.ProductMouldSize e)
 {
     return(sqlmapper.QueryForObject <Model.ProductMouldSize>("ProductMouldSize.get_next", e));
 }
示例#9
0
 public bool HasRowsAfter(Model.ProductMouldSize e)
 {
     return(sqlmapper.QueryForObject <bool>("ProductMouldSize.has_rows_after", e));
 }
示例#10
0
 public bool HasRowsBefore(Model.ProductMouldSize e)
 {
     return(sqlmapper.QueryForObject <bool>("ProductMouldSize.has_rows_before", e));
 }
示例#11
0
 public void Update(Model.ProductMouldSize e)
 {
     this.Update <Model.ProductMouldSize>(e);
 }
 public bool HasRowsAfter(Model.ProductMouldSize e)
 {
     return(accessor.HasRowsAfter(e));
 }
示例#13
0
 protected override void MoveLast()
 {
     this._productMouldSize = this._manager.GetLast();
 }
 public Model.ProductMouldSize GetNext(Model.ProductMouldSize e)
 {
     return(accessor.GetNext(e));
 }
 public Model.ProductMouldSize GetPrev(Model.ProductMouldSize e)
 {
     return(accessor.GetPrev(e));
 }
示例#16
0
 public void Insert(Model.ProductMouldSize e)
 {
     this.Insert <Model.ProductMouldSize>(e);
 }
        /// <summary>
        /// Update a ProductMouldSize.
        /// </summary>
        public void Update(Model.ProductMouldSize productMouldSize)
        {
            //
            // todo: add other logic here.
            //
            Validate(productMouldSize);
            productMouldSize.UpdateTime = DateTime.Now;
            accessor.Update(productMouldSize);

            string path = ServerSavePath + "\\" + productMouldSize.ProductMouldSizeId;

            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }

            string[] newfilenames = productMouldSize.Upload.Split('|');
            string[] hasfilenames = System.IO.Directory.GetFiles(path);

            //上传新的
            if (!string.IsNullOrEmpty(productMouldSize.Upload))
            {
                foreach (string newfile in newfilenames)
                {
                    if (newfile.Contains(ServerSavePath))
                    {
                        continue;
                    }

                    bool flag = true;
                    foreach (string hasfile in hasfilenames)
                    {
                        if (hasfile.Equals(newfile, StringComparison.OrdinalIgnoreCase))
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (flag)
                    {
                        System.IO.File.Copy(newfile, path + "\\" + newfile.Substring(newfile.LastIndexOf("\\") + 1), true);
                    }
                }
            }

            //删除旧的
            foreach (string hasfile in hasfilenames)
            {
                bool flag = true;
                foreach (string newfile in newfilenames)
                {
                    string str = newfile.Substring(newfile.LastIndexOf("\\") + 1);
                    if (str.Equals(hasfile.Substring(hasfile.LastIndexOf("\\") + 1), StringComparison.OrdinalIgnoreCase))
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    System.IO.File.Delete(hasfile);
                }
            }
        }
 public bool HasRowsBefore(Model.ProductMouldSize e)
 {
     return(accessor.HasRowsBefore(e));
 }