Пример #1
0
 public void Delete(Model.UnitGroup unitGroup)
 {
     //
     // todo:add other logic here
     //
     accessor.Delete(unitGroup.UnitGroupId);
 }
Пример #2
0
 /// <summary>
 /// 根据单位组,修改所有单位组成员主计量单位标志为false
 /// </summary>
 /// <param name="groupId"></param>
 public void Updates(Model.UnitGroup group)
 {
     //
     // todo: add other logic here.
     //
     accessor.updates(group);
 }
Пример #3
0
        public bool existsInsertName(string name, Model.UnitGroup group)
        {
            Hashtable ht = new Hashtable();

            ht.Add("name", name);
            ht.Add("groupunitd", group == null ? null : group.UnitGroupId);
            return(sqlmapper.QueryForObject <bool>("ProductUnit.existsInsertName", ht));
        }
Пример #4
0
        public bool ExistsExcept(Model.UnitGroup e)
        {
            Hashtable paras = new Hashtable();

            paras.Add("newId", e.Id);
            paras.Add("oldId", Get(e.UnitGroupId).Id);
            return(sqlmapper.QueryForObject <bool>("UnitGroup.existsexcept", paras));
        }
Пример #5
0
 protected override void LoadData()
 {
     Model.UnitGroup group = groupManager.Get(_unitGroupId);
     if (group != null)
     {
         this.bindingSource1.DataSource = (this.manager as BL.ProductUnitManager).Select(group);
         this.gridControl1.RefreshDataSource();
     }
 }
Пример #6
0
 private void bindingSourceUnitGroup_CurrentChanged(object sender, EventArgs e)
 {
     Model.UnitGroup unitGroup = this.bindingSourceUnitGroup.Current as Model.UnitGroup;
     if (unitGroup == null)
     {
         return;
     }
     this.bindingSource1.DataSource = this.unitManager.Select(unitGroup.UnitGroupId);
 }
Пример #7
0
        protected override void MovePrev()
        {
            Model.UnitGroup unitGroup = this.unitGroupManager.GetPrev(this._unitGroup);
            if (unitGroup == null)
            {
                throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows);
            }

            this._unitGroup = unitGroup;
        }
Пример #8
0
        public void MyClick(ref ChooseItem item)
        {
            ChooseUnitGroupForm f = new ChooseUnitGroupForm();

            if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                units = f.SelectedItem as Model.UnitGroup;
                item  = new ChooseItem(units, units.UnitGroupId, units.UnitGroupName);
            }
        }
Пример #9
0
        /// <summary>
        /// Insert a UnitGroup.
        /// </summary>
        public void Insert(Model.UnitGroup unitGroup)
        {
            //
            // todo:add other logic here
            //
            Validate(unitGroup);
            if (accessor.existsInsertName(unitGroup.UnitGroupName))
            {
                throw new Helper.InvalidValueException(Model.UnitGroup.PROPERTY_UNITGROUPNAME);
            }
            // unitGroup.UnitGroupId = Guid.NewGuid().ToString();
            try
            {
                unitGroup.InsertTime = DateTime.Now;
                unitGroup.UpdateTime = DateTime.Now;
                BL.V.BeginTransaction();
                string invoiceKind   = this.GetInvoiceKind().ToLower();
                string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, unitGroup.InsertTime.Value.Year);
                string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, unitGroup.InsertTime.Value.Year, unitGroup.InsertTime.Value.Month);
                string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, unitGroup.InsertTime.Value.ToString("yyyy-MM-dd"));
                string sequencekey   = string.Format(invoiceKind);

                SequenceManager.Increment(sequencekey_y);
                SequenceManager.Increment(sequencekey_m);
                SequenceManager.Increment(sequencekey_d);
                SequenceManager.Increment(sequencekey);
                accessor.Insert(unitGroup);
                if (unitGroup.Details != null)
                {
                    foreach (Model.ProductUnit productUnit in unitGroup.Details)
                    {
                        if (string.IsNullOrEmpty(productUnit.CnName))
                        {
                            continue;
                        }
                        if (ProductUnitAccessor.existsInsertName(productUnit.CnName, unitGroup))
                        {
                            throw new Helper.InvalidValueException(Model.ProductUnit.PROPERTY_CNNAME);
                        }
                        productUnit.UnitGroupId = unitGroup.UnitGroupId;
                        ProductUnitAccessor.Insert(productUnit);
                    }
                }
                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
Пример #10
0
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            if (flag == 0)
            {
                if (e.Node != null && e.Node.ParentNode == null)
                {
                    this.action     = "view";
                    this._unitGroup = unitGroupManager.Get(e.Node.Tag.ToString());

                    this.Refresh();
                }
            }
            //  flag = 0;
        }
Пример #11
0
 public void MyLeave(ref ChooseItem item)
 {
     BL.UnitGroupManager manager = new Book.BL.UnitGroupManager();
     Model.UnitGroup     unit    = manager.Get(units.UnitGroupId);
     if (unit != null)
     {
         item.EditValue  = unit;
         item.LabelText  = string.Empty;
         item.ButtonText = unit.UnitGroupName;
     }
     else
     {
         item.ErrorMessage = "单位组错误";
     }
 }
Пример #12
0
        private void Validate(Model.UnitGroup unitGroup)
        {
            //if (string.IsNullOrEmpty(unitGroup.Id))
            //{
            //    throw new Helper.RequireValueException(Model.UnitGroup.PROPERTY_ID);
            //}

            if (string.IsNullOrEmpty(unitGroup.UnitGroupName))
            {
                throw new Helper.RequireValueException(Model.UnitGroup.PROPERTY_UNITGROUPNAME);
            }

            if (string.IsNullOrEmpty(unitGroup.UnitGroupType))
            {
                throw new Helper.RequireValueException(Model.UnitGroup.PROPERTY_UNITGROUPTYPE);
            }
        }
Пример #13
0
 protected override void Delete()
 {
     if (this._unitGroup == null)
     {
         return;
     }
     if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
     {
         return;
     }
     this.unitGroupManager.Delete(this._unitGroup.UnitGroupId);
     this._unitGroup = this.unitGroupManager.GetNext(this._unitGroup);
     if (this._unitGroup == null)
     {
         this._unitGroup = this.unitGroupManager.GetLast();
     }
     flag = 1;
     TreeLoad();
 }
Пример #14
0
        /// <summary>
        /// Update a UnitGroup.
        /// </summary>
        public void Update(Model.UnitGroup unitGroup)
        {
            //
            // todo: add other logic here.
            //
            Validate(unitGroup);
            if (accessor.existsUpdateName(unitGroup.UnitGroupName, unitGroup.UnitGroupId))

            {
                throw new Helper.InvalidValueException(Model.UnitGroup.PROPERTY_UNITGROUPNAME);
            }

            unitGroup.UpdateTime = DateTime.Now;
            accessor.Update(unitGroup);
            if (unitGroup.Details != null)
            {
                foreach (Model.ProductUnit productUnit in unitGroup.Details)
                {
                    if (string.IsNullOrEmpty(productUnit.CnName))
                    {
                        continue;
                    }

                    if (ProductUnitAccessor.ExistsPrimary(productUnit.ProductUnitId))
                    {
                        if (ProductUnitAccessor.existsUpdateName(productUnit.CnName, productUnit.ProductUnitId, unitGroup))
                        {
                            throw new Helper.InvalidValueException(Model.ProductUnit.PROPERTY_CNNAME);
                        }
                        productUnit.UnitGroupId = unitGroup.UnitGroupId;
                        ProductUnitAccessor.Update(productUnit);
                    }

                    else
                    {
                        productUnit.UnitGroupId = unitGroup.UnitGroupId;
                        ProductUnitAccessor.Insert(productUnit);
                    }
                }
            }
        }
Пример #15
0
 public Model.UnitGroup GetPrev(Model.UnitGroup e)
 {
     return(sqlmapper.QueryForObject <Model.UnitGroup>("UnitGroup.get_prev", e));
 }
Пример #16
0
 /// <summary>
 /// 获取这个单位组编号的所有单位
 /// </summary>
 /// <param name="groupId">单位组编号</param>
 /// <returns>单位结合</returns>
 public IList <Model.ProductUnit> Select(Model.UnitGroup group)
 {
     return(accessor.SelectByGroup(group));
 }
Пример #17
0
 public void updates(Model.UnitGroup group)
 {
     sqlmapper.QueryForList <Model.ProductUnit>("ProductUnit.updatebygroup", group.UnitGroupId);
 }
Пример #18
0
 protected override void MoveFirst()
 {
     this._unitGroup = this.unitGroupManager.GetFirst();
 }
Пример #19
0
 public EditForm(Model.UnitGroup unitGroup)
     : this()
 {
     this.unitGroup = unitGroup;
 }
Пример #20
0
 protected override void AddNew()
 {
     this._unitGroup             = new Model.UnitGroup();
     this._unitGroup.UnitGroupId = Guid.NewGuid().ToString();
     this._unitGroup.Details     = new List <Model.ProductUnit>();
 }
Пример #21
0
 public bool HasRowsAfter(Model.UnitGroup e)
 {
     return(accessor.HasRowsAfter(e));
 }
Пример #22
0
        public override void Refresh()
        {
            if (this._unitGroup == null)
            {
                this._unitGroup         = new Book.Model.UnitGroup();
                this._unitGroup.Details = new List <Model.ProductUnit>();

                this.action = "insert";
            }
            else
            {
                if (this.action == "view")
                {
                    this._unitGroup = this.unitGroupManager.GetDetails(_unitGroup.UnitGroupId);
                }
            }
            if (this.action == "insert" || (this.action == "update" && this._unitGroup.Details.Count == 0))
            {
                Model.ProductUnit detail = new Model.ProductUnit();
                detail.UnitGroupId = Guid.NewGuid().ToString();
                detail.CnName      = "";
                detail.ConvertRate = 1;
                detail.IsMainUnit  = false;
                this._unitGroup.Details.Add(detail);
                this.bindingSourceUnitGroup.Position = this.bindingSourceUnitGroup.IndexOf(detail);
            }



            this.bindingSourceUnitGroup.DataSource = this._unitGroup.Details;
            this.gridControl1.RefreshDataSource();
            flag = 1;
            if (this.action != "view")
            {
                TreeLoad();
            }

            //this.textEditId.Text = this._unitGroup.Id;
            this.textEditUnitGroupName.EditValue = this._unitGroup.UnitGroupName;
            this.comboBoxEditUnitGroupType.Text  = this._unitGroup.UnitGroupType;
            flag = 0;
            switch (this.action)
            {
            case "insert":
                // this.textEditId.Properties.ReadOnly = false;
                this.textEditUnitGroupName.Properties.ReadOnly     = false;
                this.comboBoxEditUnitGroupType.Properties.ReadOnly = false;
                this.gridView1.OptionsBehavior.Editable            = true;
                this.simpleButton1.Enabled = true;
                this.simpleButton2.Enabled = true;

                break;

            case "update":
                // this.textEditId.Properties.ReadOnly = false ;
                this.textEditUnitGroupName.Properties.ReadOnly     = false;
                this.comboBoxEditUnitGroupType.Properties.ReadOnly = false;
                this.gridView1.OptionsBehavior.Editable            = true;
                this.simpleButton1.Enabled = true;
                this.simpleButton2.Enabled = true;
                break;

            case "view":
                // this.textEditId.Properties.ReadOnly = true;
                this.textEditUnitGroupName.Properties.ReadOnly     = true;
                this.comboBoxEditUnitGroupType.Properties.ReadOnly = true;
                this.gridView1.OptionsBehavior.Editable            = false;
                this.simpleButton1.Enabled = false;
                this.simpleButton2.Enabled = false;
                break;

            default:
                break;
            }
            base.Refresh();
        }
Пример #23
0
 public Model.UnitGroup GetPrev(Model.UnitGroup e)
 {
     return(accessor.GetPrev(e));
 }
Пример #24
0
 public void Insert(Model.UnitGroup e)
 {
     this.Insert <Model.UnitGroup>(e);
 }
Пример #25
0
 public Model.UnitGroup GetNext(Model.UnitGroup e)
 {
     return(accessor.GetNext(e));
 }
Пример #26
0
 public Model.UnitGroup GetDetails(string unitGroupId)
 {
     Model.UnitGroup unitGroup = accessor.Get(unitGroupId);
     unitGroup.Details = ProductUnitAccessor.SelectByGroup(unitGroup);
     return(unitGroup);
 }
Пример #27
0
 public void Update(Model.UnitGroup e)
 {
     this.Update <Model.UnitGroup>(e);
 }
Пример #28
0
 public bool HasRowsBefore(Model.UnitGroup e)
 {
     return(sqlmapper.QueryForObject <bool>("UnitGroup.has_rows_before", e));
 }
Пример #29
0
 public bool HasRowsAfter(Model.UnitGroup e)
 {
     return(sqlmapper.QueryForObject <bool>("UnitGroup.has_rows_after", e));
 }
Пример #30
0
 public Model.UnitGroup GetNext(Model.UnitGroup e)
 {
     return(sqlmapper.QueryForObject <Model.UnitGroup>("UnitGroup.get_next", e));
 }