private void CheckedExist(String name)
        {
            string condition             = MaterialCategoryEnum.name.ToString() + "=" + Constract.valueSplit + name + Constract.valueSplit;
            string sql                   = DatabaseOPtionHelper.GetInstance().getSelectSqlNoSoftDeleteCondition(DataTabeName.material_category.ToString(), null, condition, null, null, null, 1, 0);
            List <MaterialCategory> list = DatabaseOPtionHelper.GetInstance().select <MaterialCategory>(sql);

            if (list == null || list.Count <= 0)
            {
                this.AlertInfoTb.Text       = "该分类名称可以添加!";
                this.AlertInfoTb.Foreground = Brushes.Green;
                return;
            }
            else
            {
                mMaterialCategory = list[0];
            }
            if (mMaterialCategory != null)
            {
                if (mMaterialCategory != null)
                {
                    if (mMaterialCategory.isDelete != 1)
                    {
                        this.AlertInfoTb.Text = "该分类已经存在,不需要再添加!";
                        this.nameTb.Focus();
                    }
                }
            }
        }
예제 #2
0
        private void CateNameCb_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MaterialCategory mc = (MaterialCategory)this.CateNameCb.SelectedItem;

            mMaterial.categoryId   = mc.id;
            mMaterial.categoryName = mc.name;
        }
예제 #3
0
        private void InitCateGoryData()
        {
            String sql = DatabaseOPtionHelper.GetInstance().getSelectSql(DataTabeName.material_category.ToString());

            mMaterialCategorys          = DatabaseOPtionHelper.GetInstance().select <MaterialCategory>(sql);
            this.CateNameCb.ItemsSource = mMaterialCategorys;
            for (int i = 0; i < this.CateNameCb.Items.Count; i++)
            {
                MaterialCategory mc = (MaterialCategory)this.CateNameCb.Items[i];
                if (mc.id == mMaterial.categoryId)
                {
                    this.CateNameCb.SelectedIndex = i;
                    break;
                }
            }
        }
        private void GenerterMaterialVData()
        {
            if (mMaterialVs == null)
            {
                mMaterialVs = new List <MaterialV>();
            }
            if (materialNeedRefresh == false)
            {
                return;
            }
            else
            {
                mMaterialVs.Clear();
            }
            List <MaterialCategory> cates = new List <MaterialCategory>();
            String CategorySql            = DatabaseOPtionHelper.GetInstance().getSelectSql(DataTabeName.material_category.ToString());

            cates = DatabaseOPtionHelper.GetInstance().select <MaterialCategory>(CategorySql);
            if (cates.Count > 0)
            {
                if (cates == null || cates.Count <= 0)
                {
                    FillMaterialAlretData();
                    return;
                }
                MaterialCategory mc        = null;
                String           condition = string.Empty;
                String           sql       = string.Empty;
                for (int i = 0; i < cates.Count; i++)
                {
                    mc        = cates[i];
                    condition = MaterialEnum.category_id + "=" + Constract.valueSplit + mc.id + Constract.valueSplit;
                    sql       = DatabaseOPtionHelper.GetInstance().getSelectSql(DataTabeName.material.ToString(), null, condition);
                    List <Material> mlist = DatabaseOPtionHelper.GetInstance().select <Material>(sql);
                    MaterialV       v     = new MaterialV()
                    {
                        Category  = mc,
                        Materials = mlist
                    };
                    mMaterialVs.Add(v);
                }
            }
        }
        private void saveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(this.nameTb.Text) || this.nameTb.Text.Length < 1)
            {
                MessageBox.Show("请输入分类的名称!");
                return;
            }

            SqlDao.DbHelper optionHelper = DatabaseOPtionHelper.GetInstance();
            String          condition    = String.Empty;
            String          sql          = string.Empty;
            int             res          = 0;

            if (!String.IsNullOrEmpty(mId))
            {
                //update
                mMaterialCategory.name = this.nameTb.Text;
                if (RegexHelper.IsChineseCharacter(mMaterialCategory.name))
                {
                    mMaterialCategory.firstCase = StringHelper.GetFirstPinyin(mMaterialCategory.name);
                }
                else
                {
                    mMaterialCategory.firstCase = mMaterialCategory.name;
                }
                mMaterialCategory.syncTime = (Int32)DateTimeHelper.GetTimeStamp();
                res = DatabaseOPtionHelper.GetInstance().update(mMaterialCategory);
                if (res > 0)
                {
                    MessageBox.Show("修改成功!");
                    RefreshParentData();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("修改失败!");
                    return;
                }
            }
            else
            {
                //insert
                if (mMaterialCategory != null)
                {
                    mMaterialCategory.isDelete   = 0;
                    mMaterialCategory.deleteTime = null;
                    if (RegexHelper.IsChineseCharacter(mMaterialCategory.name))
                    {
                        mMaterialCategory.firstCase = StringHelper.GetFirstPinyin(mMaterialCategory.name);
                    }
                    else
                    {
                        mMaterialCategory.firstCase = mMaterialCategory.name;
                    }
                    mMaterialCategory.addUserId      = App.currentUser.id;
                    mMaterialCategory.addUserName    = App.currentUser.name;
                    mMaterialCategory.addUserCompany = App.currentCompany.name;
                    mMaterialCategory.syncTime       = DateTimeHelper.GetTimeStamp();
                    res = optionHelper.update(mMaterialCategory);
                }
                else
                {
                    mMaterialCategory = new MaterialCategory()
                    {
                        id             = Guid.NewGuid().ToString(),
                        name           = this.nameTb.Text.Trim(),
                        addtime        = DateTimeHelper.getCurrentDateTime(),
                        addUserId      = App.currentUser.id,
                        addUserName    = App.currentUser.name,
                        addUserCompany = App.currentCompany.name,
                        isDelete       = 0,
                        deleteTime     = null,
                        syncTime       = (Int32)DateTimeHelper.GetTimeStamp()
                    };
                    if (RegexHelper.IsChineseCharacter(mMaterialCategory.name))
                    {
                        mMaterialCategory.firstCase = StringHelper.GetFirstPinyin(mMaterialCategory.name);
                    }
                    else
                    {
                        mMaterialCategory.firstCase = mMaterialCategory.name;
                    }
                    res = optionHelper.insert(mMaterialCategory);
                }
                if (res > 0)
                {
                    MessageBox.Show("保存成功!");
                    RefreshParentData();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败!");
                    return;
                }
            }
        }