/// <summary> /// Insert a ProductMould. /// </summary> public void Insert(Model.ProductMould productMould) { validate(productMould); productMould.InsertTime = DateTime.Now; productMould.UpdateTime = DateTime.Now; accessor.Insert(productMould); foreach (Model.MouldAttachment item in productMould.Details) { item.InsertTime = System.DateTime.Now; item.UpdateTime = System.DateTime.Now; MouldAttachmentAccessor.Insert(item); } //上传附件 if (!string.IsNullOrEmpty(productMould.Upload)) { string sfdir = this.ServerSavePath + "\\" + productMould.MouldId; try { System.IO.Directory.CreateDirectory(sfdir); } catch (Exception ex) { throw new Helper.MessageValueException(ex.Message); } foreach (string fn in productMould.Upload.Split('|')) { if (!fn.Contains(this.ServerSavePath)) { System.IO.File.Copy(fn, sfdir + "\\" + fn.Substring(fn.LastIndexOf("\\") + 1), true); } } } }
public bool ExistsExcept(Model.ProductMould e) { Hashtable paras = new Hashtable(); paras.Add("newId", e.Id); paras.Add("oldId", Get(e.MouldId).Id); return(sqlmapper.QueryForObject <bool>("ProductMould.existsexcept", paras)); }
protected override void Delete() { if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } Model.ProductMould productMould = this.bindingSource1.Current as Model.ProductMould; this._proMouldManager.Delete(this._productMould); }
protected override void MoveLast() { if (this.sign == 1) { this.sign = 0; return; } this._productMould = this._proMouldManager.GetLast(); }
private void repositoryItemHyperLinkEdit1_Click(object sender, EventArgs e) { this._productMould = this.bindingSource1.Current as Model.ProductMould; if (_productMould != null) { this.action = "view"; this.Refresh(); } }
public ProductMouldEditForm(string s) : this() { this._productMould = this._proMouldManager.SelectByMouldId(s); if (this._productMould != null) { this.sign = 1; } this.action = "view"; }
protected override void MovePrev() { Model.ProductMould pro = this._proMouldManager.GetPrev(this._productMould); if (pro == null) { throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows); } this._productMould = pro; }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { ProductMouldEditFormList f = new ProductMouldEditFormList(); if (f.ShowDialog(this) == DialogResult.OK) { Model.ProductMould model = f.SelectItem as Model.ProductMould; if (model != null) { this._productMould = model; this.Refresh(); } } }
public void Delete(Model.ProductMould pro) { try { BL.V.BeginTransaction(); //ProductMouldTestDetailAccessor.DeleteByMouldId(pro.MouldId); ProductMouldDetailAccessor.DeleteByMouldId(pro.MouldId); //(new BL.ProductMouldTestManager()).DeleteByMouldId(pro.MouldId); this.Delete(pro.MouldId); BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
public bool HasRowsAfter(Model.ProductMould e) { return(sqlmapper.QueryForObject <bool>("ProductMould.has_rows_after", e)); }
public bool HasRowsBefore(Model.ProductMould e) { return(sqlmapper.QueryForObject <bool>("ProductMould.has_rows_before", e)); }
public void Update(Model.ProductMould e) { this.Update <Model.ProductMould>(e); }
public void Insert(Model.ProductMould e) { this.Insert <Model.ProductMould>(e); }
public bool HasRowsBefore(Model.ProductMould e) { return(accessor.HasRowsBefore(e)); }
public bool HasRowsAfter(Model.ProductMould e) { return(accessor.HasRowsAfter(e)); }
public Model.ProductMould GetPrev(Model.ProductMould e) { return(accessor.GetPrev(e)); }
/// <summary> /// Update a ProductMould. /// </summary> public void Update(Model.ProductMould productMould) { validate(productMould); productMould.UpdateTime = DateTime.Now; accessor.Update(productMould); MouldAttachmentAccessor.DeleteByMouldid(productMould.MouldId); foreach (Model.MouldAttachment item in productMould.Details) { item.InsertTime = System.DateTime.Now; item.UpdateTime = System.DateTime.Now; MouldAttachmentAccessor.Insert(item); } string path = ServerSavePath + "\\" + productMould.MouldId; if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } string[] newfilenames = productMould.Upload.Split('|'); string[] hasfilenames = System.IO.Directory.GetFiles(path); //上传新的 if (!string.IsNullOrEmpty(productMould.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 ExistsExcept(Model.ProductMould e) { return(accessor.ExistsExcept(e)); }
protected override void AddNew() { this._productMould = new Book.Model.ProductMould(); this._productMould.MouldId = Guid.NewGuid().ToString(); }
public Model.ProductMould GetNext(Model.ProductMould e) { return(sqlmapper.QueryForObject <Model.ProductMould>("ProductMould.get_next", e)); }
public Model.ProductMould GetNext(Model.ProductMould e) { return(accessor.GetNext(e)); }
public override void Refresh() { if (this._productMould == null) { this.AddNew(); this.action = "insert"; } if (this.action == "view") { this._productMould = this._proMouldManager.Get(this._productMould.MouldId); if (this._productMould == null) { this.AddNew(); this.action = "insert"; } } this.textEditId.Text = this._productMould.Id; this.textEditMouldName.Text = this._productMould.MouldName; //this.buttonEditProductId.EditValue = this._productMould.Product; if (this._productMould.SupplierId != "") { this.newChooseContorlSupplierId.EditValue = this._productMould.Supplier; } if (this._productMould.MouldCategoryId != "") { this.lookUpEditMouldCategoryId.EditValue = this._productMould.MouldCategoryId; } //this.textEditMachineKind.Text = this._productMould.MachineKind; this.textEditMouldSpecification.Text = this._productMould.MouldSpecification; //this.textEditProductSpecification.Text = this._productMould.ProductSpecification; //if (this._productMould.Employee0Id != null) // this.newChooseContorlEmployee0Id.EditValue = this._productMould.Employee0Id; //if (this._productMould.EmployeeId != null) // this.newChooseContorlEmployeeId.EditValue = this._productMould.EmployeeId; this.newChooseContorlEmployee0Id.EditValue = this._productMould.Employee0; this.newChooseContorlEmployeeId.EditValue = this._productMould.Employee; //this.newChooseContorlKeeper.EditValue = this._productMould.Keeper; if (this._productMould.MouldMaterial != null) { this.lookUpEditMouldMaterial.EditValue = this._productMould.MouldMaterial; } this.memoEditMouldDescription.Text = this._productMould.MouldDescription; //this.textEditpartName.Text = this._productMould.PartName; this.spinEditpartWeight.Text = this._productMould.PartWeight.ToString(); this.spinEditMouldPrice.Text = this._productMould.MouldPrice.ToString(); this.textEditMouldBarCode.Text = this._productMould.MouldBarCode; if (this._productMould.CodeIsAotu != null) { if (this._productMould.CodeIsAotu.Value) { this.radioGroup.SelectedIndex = 1; } } else { this.radioGroup.SelectedIndex = 0; } if (this._productMould.DoubleCount != null) { this.spinEditDoubleCount.Text = this._productMould.DoubleCount.Value.ToString(); } else { this.spinEditDoubleCount.Text = "0"; } //if (this._productMould.StartTime != null && this._productMould.StartTime != new DateTime() && this._productMould.StartTime != global::Helper.DateTimeParse.NullDate) // this.dateEditStartTime.Text = this._productMould.StartTime.ToString(); //else // this.dateEditStartTime.DateTime = System.DateTime.Now; //if (this._productMould.FirstTime != null && this._productMould.FirstTime != new DateTime() && this._productMould.FirstTime != global::Helper.DateTimeParse.NullDate) // this.dateEditFirstTime.Text = this._productMould.FirstTime.ToString(); //else // this.dateEditFirstTime.Text = ""; //if (this._productMould.OkTime != null && this._productMould.OkTime != new DateTime() && this._productMould.OkTime != global::Helper.DateTimeParse.NullDate) // this.dateEditOkTime.Text = this._productMould.OkTime.ToString(); //else // this.dateEditOkTime.DateTime = System.DateTime.Now; this.dateEditStartTime.EditValue = this._productMould.StartTime; this.dateEditFirstTime.EditValue = this._productMould.FirstTime; this.dateEditOkTime.EditValue = this._productMould.OkTime; //this.buttonEdit1.Text = ""; //this.memoEditDescription.Text = "1"; //this.pictureEditpic.Image = null; this.bindingSource1.DataSource = this._proMouldManager.Select(); this._productMould.Details = this._mouldattenachmentManager.SelectByMouldId(this._productMould); //this.bindingSourceDetails.DataSource = this._productMould.Details; if (this._productMould.Details.Count > 0) { if (this._mouldattachment == null) { this._mouldattachment = this._mouldattenachmentManager.GetFirst(); } //if (this._mouldattachment.Picture != null && this._mouldattachment.Picture.Length > 0) // this.pictureEditpic.Image = Image.FromStream(new System.IO.MemoryStream(this._mouldattachment.Picture)); } //else // this.pictureEditpic.Image = null; //获取已上传文件列表 GetHasUpLoadFiles(); base.Refresh(); switch (this.action) { case "insert": break; case "update": //if (this._productMould.OkTime.HasValue) //{ // this.dateEditOkTime.Properties.ReadOnly = true; //} //else //{ // this.dateEditOkTime.Properties.ReadOnly = false; //} break; case "view": break; } }
public IList <Model.MouldAttachment> SelectByMouldId(Model.ProductMould mould) { return(accessor.SelectByMouldId(mould)); }
protected override void MoveFirst() { this._productMould = this._proMouldManager.GetFirst(); }
public Model.ProductMould GetPrev(Model.ProductMould e) { return(sqlmapper.QueryForObject <Model.ProductMould>("ProductMould.get_prev", e)); }
public IList <Model.MouldAttachment> SelectByMouldId(Model.ProductMould mould) { return(sqlmapper.QueryForList <Model.MouldAttachment>("MouldAttachment.selectByMouldId", mould.MouldId)); }