Пример #1
0
        /// <summary>
        /// 改变选中行事件
        /// </summary>
        /// <param name="sender">对象</param>
        /// <param name="e">参数</param>
        private void dgDrugType_CurrentCellChanged(object sender, EventArgs e)
        {
            if (dgDrugType.CurrentCell == null)
            {
                return;
            }

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

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

            CurrentDataP           = pType;
            this.txtDrugTypeA.Text = pType.TypeName;

            #region 加载子表
            QueryConditionC = new Dictionary <string, string>();
            string p;
            if (!QueryConditionC.TryGetValue("TypeID", out p))
            {
                QueryConditionC.Add("TypeID", pType.TypeID.ToString());
            }

            InvokeController("GetChildDrugType");
            #endregion
        }
Пример #2
0
        /// <summary>
        /// 点击事件
        /// </summary>
        /// <param name="sender">对象</param>
        /// <param name="e">参数</param>
        private void dgDrugType_Click(object sender, EventArgs e)
        {
            if (dgDrugType.CurrentCell == null)
            {
                return;
            }

            int       rowindex = dgDrugType.CurrentCell.RowIndex;
            DataTable dt       = (DataTable)dgDrugType.DataSource;
            var       pType    = new DG_TypeDic();

            pType.TypeName         = dt.Rows[rowindex]["TypeName"].ToString();
            pType.TypeID           = Convert.ToInt32(dt.Rows[rowindex]["TypeID"]);
            pType.PYCode           = dt.Rows[rowindex]["PYCode"].ToString();
            pType.WBCode           = dt.Rows[rowindex]["WBCode"].ToString();
            CurrentDataP           = pType;
            this.txtDrugTypeA.Text = pType.TypeName;
            #region 加载子表
            QueryConditionC = new Dictionary <string, string>();
            string p;
            if (!QueryConditionC.TryGetValue("TypeID", out p))
            {
                QueryConditionC.Add("TypeID", pType.TypeID.ToString());
            }

            InvokeController("GetChildDrugType");
            #endregion
        }
Пример #3
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="typeDic">实体对象</param>
        /// <returns>是否成功</returns>
        public bool SaveDrugType(DG_TypeDic typeDic)
        {
            List <Tuple <string, string, SqlOperator> > lst = new List <Tuple <string, string, SqlOperator> >();

            lst.Add(Tuple.Create("TypeName", typeDic.TypeName, SqlOperator.Equal));
            IEnumerable <DG_TypeDic> objs = NewObject <IDGDao>().GetEntityType <DG_TypeDic>(lst, null);

            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);
        }
Пример #4
0
        public ServiceResponseData SaveDrugType()
        {
            DG_TypeDic drugProduct = NewObject <DG_TypeDic>();
            var        p           = requestData.GetData <DG_TypeDic>(0);

            this.BindDb(p);
            var flag = NewObject <DrugTypeMgr>().SaveDrugType(p);

            responseData.AddData(flag);
            return(responseData);
        }
Пример #5
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender">对象</param>
        /// <param name="e">参数</param>
        private void btn_SaveP_Click(object sender, EventArgs e)
        {
            if (this.txtDrugTypeA.Text.Trim() == string.Empty)
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("类型名称不能为空");
                return;
            }

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

            DG_TypeDic productType = null;

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

                productType = CurrentDataP;
            }
            else
            {
                productType = new DG_TypeDic();
            }

            productType.TypeName = this.txtDrugTypeA.Text;
            int rowindex = 0;

            if (dgDrugType.CurrentCell != null)
            {
                rowindex = dgDrugType.CurrentCell.RowIndex;
            }

            productType.TypeName = this.txtDrugTypeA.Text.Trim();
            productType.PYCode   = EFWCoreLib.CoreFrame.Common.SpellAndWbCode.GetSpellCode(productType.TypeName);
            productType.WBCode   = EFWCoreLib.CoreFrame.Common.SpellAndWbCode.GetWBCode(productType.TypeName);
            CurrentDataP         = productType;
            InvokeController("SaveDrugType");
            if (rowindex != 0)
            {
                dgDrugType.CurrentCell = dgDrugType[1, rowindex];
            }

            CurrentDataP      = null;
            txtDrugTypeA.Text = string.Empty;
            txtDrugTypeA.Focus();
        }