Esempio n. 1
0
        /// <summary>
        /// insert Or Update App Settings
        /// </summary>
        private void InsertOrUpdateAppSettings()
        {
            SqlDao.DbHelper     helper     = DatabaseOPtionHelper.GetInstance();;
            string              sql        = string.Empty;
            NameValueCollection collection = ConfigurationManager.AppSettings;

            string[] keys = collection.AllKeys;
            foreach (string key in keys)
            {
                Config config = null;
                sql = helper.getSelectSql("config", null, "client_id ='" + ConfigurationHelper.GetConfig(ConfigItemName.clientId.ToString()) + "' and config_name = '" + key + "'", null, null, null, 1);
                List <Config> configs = helper.select <Config>(sql);
                if (configs != null && configs.Count > 0)
                {
                    if (configs[0] != null)
                    {
                        config = configs[0];
                        if (config.configValue != collection[key].ToString())
                        {
                            config.configValue = collection[key].ToString();
                            config.syncTime    = DateTimeHelper.ConvertDateTimeToInt(DateTime.Now);
                            config.updateTime  = DateTimeHelper.getCurrentDateTime();
                            if (App.currentUser != null)
                            {
                                config.updateUserId   = config.addUserId;
                                config.updateUserName = config.addUserName;
                            }
                        }
                        helper.update(config);
                    }
                    else
                    {
                        //conveter error
                    }
                }
                else
                {
                    config = new Config
                    {
                        id          = Guid.NewGuid().ToString(),
                        addtime     = DateTimeHelper.getCurrentDateTime(),
                        configName  = key,
                        clientId    = ConfigurationHelper.GetConfig(ConfigItemName.clientId.ToString()),
                        configValue = collection[key].ToString(),
                        configType  = (int)ConfigType.ClientAppConfig
                    };
                    config.updateTime = config.addtime;
                    config.syncTime   = DateTimeHelper.ConvertDateTimeToInt(DateTime.Now);
                    if (App.currentUser != null)
                    {
                        config.addUserId      = App.currentUser.id;
                        config.addUserName    = App.currentUser.name;
                        config.updateUserId   = config.addUserId;
                        config.updateUserName = config.addUserName;
                    }
                    helper.insert(config);
                }
            }
        }
        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;
                }
            }
        }
        private void saveBtn_Click(object sender, RoutedEventArgs e)
        {
            SqlDao.DbHelper optionHelper = DatabaseOPtionHelper.GetInstance();
            int             res          = 0;

            if (isAdd == false)
            {
                //update
                mYard.name     = this.nameTb.Text;
                mYard.syncTime = (Int32)DateTimeHelper.GetTimeStamp();
                res            = optionHelper.update(mYard);
                if (res > 0)
                {
                    MessageBox.Show("修改成功!");
                    RefreshParentData();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("修改失败!");
                    return;
                }
            }
            else
            {
                //insert
                if (mYard.isDelete == 1)
                {
                    mYard.isDelete   = 0;
                    mYard.deleteTime = null;
                    mYard.syncTime   = DateTimeHelper.GetTimeStamp();
                    res = optionHelper.update(mYard);
                }
                else
                {
                    if (String.IsNullOrEmpty(mYard.affiliatedCompanyId) || String.IsNullOrEmpty(mYard.affiliatedCompany))
                    {
                        MessageBox.Show("添加货场名称必须先选择货场的所属公司!");
                        return;
                    }
                    mYard.name        = this.nameTb.Text.Trim();
                    mYard.addTime     = DateTimeHelper.getCurrentDateTime();
                    mYard.addUserId   = App.currentUser.id;
                    mYard.addUserName = App.currentUser.name;
                    mYard.isDelete    = 0;
                    mYard.deleteTime  = null;
                    mYard.syncTime    = DateTimeHelper.GetTimeStamp();
                    res = optionHelper.insert(mYard);
                }
                if (res > 0)
                {
                    MessageBox.Show("保存成功!");
                    RefreshParentData();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败!");
                    return;
                }
            }
        }
Esempio n. 4
0
        private void saveBtn_Click(object sender, RoutedEventArgs e)
        {
            SqlDao.DbHelper optionHelper = DatabaseOPtionHelper.GetInstance();
            int             res          = 0;

            if (!String.IsNullOrEmpty(mMaterial.id))
            {
                //update
                mMaterial.name          = this.nameTb.Text;
                mMaterial.nameFirstCase = StringHelper.GetFirstPinyin(mMaterial.name);
                mMaterial.syncTime      = (Int32)DateTimeHelper.GetTimeStamp();
                res = optionHelper.update(mMaterial);
                if (res > 0)
                {
                    MessageBox.Show("修改成功!");
                    RefreshParentData();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("修改失败!");
                    return;
                }
            }
            else
            {
                //insert
                if (mMaterial.isDelete == 1)
                {
                    mMaterial.isDelete       = 0;
                    mMaterial.deleteTime     = null;
                    mMaterial.nameFirstCase  = StringHelper.GetFirstPinyin(mMaterial.name);
                    mMaterial.updateTime     = DateTimeHelper.getCurrentDateTime();
                    mMaterial.updateUserId   = App.currentUser.id;
                    mMaterial.updateUserName = App.currentUser.name;
                    mMaterial.syncTime       = DateTimeHelper.GetTimeStamp();
                    res = optionHelper.update(mMaterial);
                }
                else
                {
                    if (String.IsNullOrEmpty(mMaterial.categoryId) || String.IsNullOrEmpty(mMaterial.categoryName))
                    {
                        MessageBox.Show("添加物资名称必须先选择物资的分类!");
                        return;
                    }
                    mMaterial.id            = Guid.NewGuid().ToString();
                    mMaterial.name          = this.nameTb.Text.Trim();
                    mMaterial.addtime       = DateTimeHelper.getCurrentDateTime();
                    mMaterial.addUserId     = App.currentUser.id;
                    mMaterial.addUserName   = App.currentUser.name;
                    mMaterial.isDelete      = 0;
                    mMaterial.deleteTime    = null;
                    mMaterial.syncTime      = DateTimeHelper.GetTimeStamp();
                    mMaterial.nameFirstCase = StringHelper.GetFirstPinyin(mMaterial.name);
                    res = optionHelper.insert(mMaterial);
                }
                if (res > 0)
                {
                    MessageBox.Show("保存成功!");

                    new System.Threading.Thread(new System.Threading.ThreadStart(() => {
                        String condition = MaterialCategoryEnum.id.ToString() + "=" + Constract.valueSplit + mMaterial.categoryId + Constract.valueSplit;
                        CommonModel.FieldTryAsc(DataTabeName.material_category.ToString(), MaterialCategoryEnum.children_count.ToString(), 1, condition);
                    })).Start();

                    RefreshParentData();
                    ChangeCategoryChildredCount();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败!");
                    return;
                }
            }
        }