Beispiel #1
0
        /// <summary>
        /// 保存物资字典信息
        /// </summary>
        /// <param name="dic">物资中心字典实体</param>
        /// <returns>true存在</returns>
        public bool SaveMaterialDic(MW_CenterSpecDic dic)
        {
            List <Tuple <string, string, SqlOperator> > andWhere = new List <Tuple <string, string, SqlOperator> >();

            andWhere.Add(Tuple.Create("CenterMatName", dic.CenterMatName, SqlOperator.Equal));
            andWhere.Add(Tuple.Create("Spec", dic.Spec, SqlOperator.Equal));
            var  t      = NewObject <IMWDao>().GetDataTable <MW_CenterSpecDic>(andWhere, null);
            bool isExit = false;

            if (dic.CenterMatID == 0)
            {
                if (t.Rows.Count > 0)
                {
                    isExit = true;
                }
            }

            if (!isExit)
            {
                this.BindDb(dic);
                int id = dic.save();
            }

            return(isExit);
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender">控件</param>
        /// <param name="e">参数</param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool isNew = false;

            if (fmCommon.Validate())
            {
                MW_CenterSpecDic dic = null;
                if (CurrentData != null)
                {
                    dic = CurrentData;
                    if (MessageBox.Show("确定更改记录?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                }
                else
                {
                    isNew = true;
                    dic   = new MW_CenterSpecDic();
                }

                try
                {
                    fmCommon.GetValue <MW_CenterSpecDic>(dic);
                    dic.TypeID        = Convert.ToInt32(this.tbMaterType.MemberValue);
                    dic.CenterMatCode = this.txtCode.Text;
                    dic.UnitName      = this.tbMinUnit.Text;
                    dic.UnitID        = 0;
                    System.Globalization.NumberFormatInfo provider = new System.Globalization.NumberFormatInfo();
                    provider.PercentDecimalDigits = 4;
                    dic.RetailPrice = 0;
                    dic.StockPrice  = 0;
                    dic.PyCode      = EFWCoreLib.CoreFrame.Common.SpellAndWbCode.GetSpellCode(dic.CenterMatName);
                    dic.WbCode      = EFWCoreLib.CoreFrame.Common.SpellAndWbCode.GetWBCode(dic.CenterMatName);
                    CurrentData     = dic;
                    InvokeController("SaveMaterialDic", frmName);
                    LoadTable();
                    if (isNew)
                    {
                        setGridSelectIndex(dataGrid, dataGrid.RowCount - 1);
                        if (frmName != "FrmMaterialDic")
                        {
                            this.superTabControl2.SelectedPanel = superTabControlPanel4;
                            btnHospAdd_Click(null, null);
                        }
                    }
                    else
                    {
                        setGridSelectIndex(dataGrid);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存失败" + ex.Message);
                    throw;
                }
            }
        }
        /// <summary>
        /// 获取当前选中行信息
        /// </summary>
        /// <param name="rowindex">行号</param>
        public void GetCurrentInfo(int rowindex)
        {
            DataTable        dt  = (DataTable)dataGrid.DataSource;
            MW_CenterSpecDic dic = new MW_CenterSpecDic();

            dic         = EFWCoreLib.CoreFrame.Common.ConvertExtend.ToObject <MW_CenterSpecDic>(dt, rowindex);
            CurrentData = dic;
            fmCommon.Load <MW_CenterSpecDic>(dic);
            tbMaterType.MemberValue = dt.Rows[rowindex]["TypeID"].ToString();
        }
        /// <summary>
        /// 选中物资字典显示字典详情
        /// </summary>
        /// <param name="sender">控件</param>
        /// <param name="e">参数</param>
        private void dataGrid_CurrentCellChanged(object sender, EventArgs e)
        {
            //this.fmCommon.Clear();
            if (dataGrid.CurrentCell == null)
            {
                return;
            }

            CurrentData = null;
            int rowindex = dataGrid.CurrentCell.RowIndex;

            GetCurrentInfo(rowindex);
            if (frmName == "FrmHisMaterialDic")
            {
                InvokeController("LoadHisDic", CurrentData.CenterMatID);
            }
        }
 /// <summary>
 /// 新增规格
 /// </summary>
 /// <param name="sender">控件</param>
 /// <param name="e">参数</param>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     CurrentData = null;
     this.fmCommon.Clear();
     this.txtCode.Focus();
 }