Exemplo n.º 1
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="typeDic">类型字典实体</param>
        /// <returns>true成功false存在相同</returns>
        public bool SaveMaterialType(MW_TypeDic typeDic)
        {
            List <Tuple <string, string, SqlOperator> > lst = new List <Tuple <string, string, SqlOperator> >();

            lst.Add(Tuple.Create("TypeName", typeDic.TypeName, SqlOperator.Equal));
            lst.Add(Tuple.Create("ParentID", typeDic.ParentID.ToString(), SqlOperator.Equal));
            IEnumerable <MW_TypeDic> objs = NewObject <IMWDao>().GetEntityType <MW_TypeDic>(lst, null).Where(item => item.ParentID == 0);

            //同名记录存在
            if (objs != null && objs.Any())
            {
                if (objs.Count() > 1)
                {
                    return(false);
                }

                var t = objs.FirstOrDefault(i => i.TypeID == typeDic.TypeID);

                //完全没修过
                if (t != null)
                {
                    typeDic.save();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            typeDic.save();
            return(true);
        }
        public ServiceResponseData SaveMaterialType()
        {
            MW_TypeDic drugProduct = NewObject <MW_TypeDic>();
            var        p           = requestData.GetData <MW_TypeDic>(0);

            this.BindDb(p);
            SetWorkId(oleDb.WorkId);
            var flag = NewObject <MaterialTypeMgr>().SaveMaterialType(p);

            responseData.AddData(flag);
            return(responseData);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 选中物资子类型
        /// </summary>
        /// <param name="sender">控件</param>
        /// <param name="e">参数</param>
        private void dgMaterialChildType_CurrentCellChanged(object sender, EventArgs e)
        {
            if (dgMaterialChildType.CurrentCell == null)
            {
                this.txtChildTypeName.Text = string.Empty;
                CurrentDataC = null;
                return;
            }

            int       rowindex = dgMaterialChildType.CurrentCell.RowIndex;
            DataTable dt       = (DataTable)dgMaterialChildType.DataSource;

            MW_TypeDic pType = EFWCoreLib.CoreFrame.Common.ConvertExtend.ToObject <MW_TypeDic>(dt, rowindex);

            CurrentDataC = pType;
            this.txtChildTypeName.Text = pType.TypeName;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 删除子类型
        /// </summary>
        /// <param name="sender">控件</param>
        /// <param name="e">参数</param>
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (CurrentDataC == null)
            {
                MessageBoxEx.Show("请选择要删除的记录");
                return;
            }

            if (MessageBox.Show("确定删除记录?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            MW_TypeDic productCType = CurrentDataC;

            InvokeController("DelChildMaterialType");
            CurrentDataC = null;
            InvokeController("GetMaterialType");
        }
Exemplo n.º 5
0
        /// <summary>
        /// 选中物资子类型
        /// </summary>
        /// <param name="sender">控件</param>
        /// <param name="e">参数</param>
        private void dgMaterialChildType_Click(object sender, EventArgs e)
        {
            if (dgMaterialChildType.CurrentCell == null)
            {
                return;
            }

            int       rowindex = dgMaterialChildType.CurrentCell.RowIndex;
            DataTable dt       = (DataTable)dgMaterialChildType.DataSource;

            var pType = new MW_TypeDic();

            pType.TypeID               = Convert.ToInt32(dt.Rows[rowindex]["TypeID"]);
            pType.TypeName             = dt.Rows[rowindex]["TypeName"].ToString();
            pType.ParentID             = Convert.ToInt32(dt.Rows[rowindex]["ParentID"]);
            pType.PYCode               = dt.Rows[rowindex]["PYCode"].ToString();
            pType.WBCode               = dt.Rows[rowindex]["WBCode"].ToString();
            CurrentDataC               = pType;
            this.txtChildTypeName.Text = pType.TypeName;
        }
Exemplo n.º 6
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender">控件</param>
        /// <param name="e">参数</param>
        private void btnSaveC_Click(object sender, EventArgs e)
        {
            if (this.txtChildTypeName.Text.Trim() == string.Empty)
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("物资类型名称不能为空");
                return;
            }

            if (this.txtChildTypeName.Text.Trim().Length > 10)
            {
                MessageBoxEx.Show("名称长度不能大于10");
                return;
            }

            if (this.advTree.SelectedNode == null)
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("请选择物资父类型");
                return;
            }

            MW_TypeDic productCType = null;

            if (CurrentDataC != null)
            {
                if (MessageBox.Show("确定更改记录?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                productCType = CurrentDataC;
            }
            else
            {
                productCType = new MW_TypeDic();
            }

            int rowindexchild = 0;

            if (dgMaterialChildType.CurrentCell != null)
            {
                rowindexchild = dgMaterialChildType.CurrentCell.RowIndex;
            }

            productCType.TypeName = this.txtChildTypeName.Text.Trim();
            productCType.PYCode   = EFWCoreLib.CoreFrame.Common.SpellAndWbCode.GetSpellCode(productCType.TypeName);
            productCType.WBCode   = EFWCoreLib.CoreFrame.Common.SpellAndWbCode.GetWBCode(productCType.TypeName);
            productCType.ParentID = Convert.ToInt32(this.advTree.SelectedNode.Tag);
            if (this.advTree.SelectedNode.Level > 3)
            {
                MessageBoxEx.Show("三级节点不能添加子类");
                return;
            }
            else
            {
                productCType.Level = this.advTree.SelectedNode.Level + 1;
            }

            CurrentParentNode = this.advTree.SelectedNode;
            CurrentDataC      = productCType;
            InvokeController("SaveChildMaterialType");

            if (rowindexchild != 0)
            {
                dgMaterialChildType.CurrentCell = dgMaterialChildType[0, rowindexchild];
            }

            CurrentDataC = null;
            InvokeController("GetMaterialType");
        }