Exemple #1
0
 public void Delete(Model.UnitGroup unitGroup)
 {
     //
     // todo:add other logic here
     //
     accessor.Delete(unitGroup.UnitGroupId);
 }
Exemple #2
0
 /// <summary>
 /// 根据单位组,修改所有单位组成员主计量单位标志为false
 /// </summary>
 /// <param name="groupId"></param>
 public void Updates(Model.UnitGroup group)
 {
     //
     // todo: add other logic here.
     //
     accessor.updates(group);
 }
        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));
        }
Exemple #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));
        }
Exemple #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();
     }
 }
Exemple #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);
 }
Exemple #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;
        }
Exemple #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);
            }
        }
        /// <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;
            }
        }
Exemple #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;
        }
Exemple #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 = "单位组错误";
     }
 }
Exemple #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);
            }
        }
Exemple #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();
 }
Exemple #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);
                    }
                }
            }
        }
Exemple #15
0
 public Model.UnitGroup GetPrev(Model.UnitGroup e)
 {
     return(sqlmapper.QueryForObject <Model.UnitGroup>("UnitGroup.get_prev", e));
 }
Exemple #16
0
 /// <summary>
 /// 获取这个单位组编号的所有单位
 /// </summary>
 /// <param name="groupId">单位组编号</param>
 /// <returns>单位结合</returns>
 public IList <Model.ProductUnit> Select(Model.UnitGroup group)
 {
     return(accessor.SelectByGroup(group));
 }
 public void updates(Model.UnitGroup group)
 {
     sqlmapper.QueryForList <Model.ProductUnit>("ProductUnit.updatebygroup", group.UnitGroupId);
 }
Exemple #18
0
 protected override void MoveFirst()
 {
     this._unitGroup = this.unitGroupManager.GetFirst();
 }
Exemple #19
0
 public EditForm(Model.UnitGroup unitGroup)
     : this()
 {
     this.unitGroup = unitGroup;
 }
Exemple #20
0
 protected override void AddNew()
 {
     this._unitGroup             = new Model.UnitGroup();
     this._unitGroup.UnitGroupId = Guid.NewGuid().ToString();
     this._unitGroup.Details     = new List <Model.ProductUnit>();
 }
Exemple #21
0
 public bool HasRowsAfter(Model.UnitGroup e)
 {
     return(accessor.HasRowsAfter(e));
 }
Exemple #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();
        }
Exemple #23
0
 public Model.UnitGroup GetPrev(Model.UnitGroup e)
 {
     return(accessor.GetPrev(e));
 }
Exemple #24
0
 public void Insert(Model.UnitGroup e)
 {
     this.Insert <Model.UnitGroup>(e);
 }
Exemple #25
0
 public Model.UnitGroup GetNext(Model.UnitGroup e)
 {
     return(accessor.GetNext(e));
 }
Exemple #26
0
 public Model.UnitGroup GetDetails(string unitGroupId)
 {
     Model.UnitGroup unitGroup = accessor.Get(unitGroupId);
     unitGroup.Details = ProductUnitAccessor.SelectByGroup(unitGroup);
     return(unitGroup);
 }
Exemple #27
0
 public void Update(Model.UnitGroup e)
 {
     this.Update <Model.UnitGroup>(e);
 }
Exemple #28
0
 public bool HasRowsBefore(Model.UnitGroup e)
 {
     return(sqlmapper.QueryForObject <bool>("UnitGroup.has_rows_before", e));
 }
Exemple #29
0
 public bool HasRowsAfter(Model.UnitGroup e)
 {
     return(sqlmapper.QueryForObject <bool>("UnitGroup.has_rows_after", e));
 }
Exemple #30
0
 public Model.UnitGroup GetNext(Model.UnitGroup e)
 {
     return(sqlmapper.QueryForObject <Model.UnitGroup>("UnitGroup.get_next", e));
 }