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);
                }
            }
        }
Esempio n. 2
0
 private void Insert()
 {
     if (ValidateInput() == false)
     {
         return;
     }
     BuildUserInfo();
     BuilderCarInfo();
     mDrivingLicense.affiliatedUserId = mDriver.id;
     mVchicleLicense.affiliatedCarId  = mCarInfo.id;
     SqlDao.DbHelper helper = DatabaseOPtionHelper.GetInstance();
     try
     {
         int      res  = 0;
         String[] sqls = new string[] {
             DatabaseOPtionHelper.GetInstance().getInsertSql(mDriver),
             DatabaseOPtionHelper.GetInstance().getInsertSql(mCarInfo),
             DatabaseOPtionHelper.GetInstance().getInsertSql(mVchicleLicense),
             DatabaseOPtionHelper.GetInstance().getInsertSql(mDrivingLicense)
         };
         res = helper.TransactionExecute(sqls);
         if (res > 0)
         {
             MessageBox.Show("保存成功!");
             AddCarHeader();
             this.Close();
             this.ParentRefreshData(false, false, true);
         }
         else
         {
             MessageBox.Show("保存失败!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("保存出错:" + ex.Message);
         return;
     }
 }
        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. 5
0
        private void saveBtn_Click(object sender, RoutedEventArgs e)
        {
            //抓图
            //if (isInitSDK && isPreviewSuccess) {
            //    CameraHelper.captureJpeg(Guid.NewGuid().ToString()+".jpg",currCameraId,1);
            //    CameraHelper.captureBmp(Guid.NewGuid().ToString() + ".bmp",currCameraId);
            //}else{
            //    ConsoleHelper.writeLine("captureJpeg failured");
            //}

            if (!IsInitialized)
            {
                MessageBox.Show("摄像头初始化失败!");
                return;
            }

            if (!isPreviewSuccess)
            {
                MessageBox.Show("保存摄像头之前必须先预览成功!");
                return;
            }

            if (checkInput())
            {
                String condition = String.Empty;
                String sql       = string.Empty;
                if (!String.IsNullOrEmpty(mId))
                {
                    //update
                    mCameraInfo.syncTime = (int)DateTimeHelper.GetTimeStamp();
                    mCameraInfo.ip       = this.IpTB.Text.Trim();
                    mCameraInfo.port     = this.portTB.Text.Trim();
                    mCameraInfo.userName = this.userNameTB.Text.Trim();
                    mCameraInfo.password = this.pwdTB.Text.Trim();
                    int res = DatabaseOPtionHelper.GetInstance().update(mCameraInfo);
                    if (res > 0)
                    {
                        MessageBox.Show("修改成功!");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("修改失败!");
                        return;
                    }
                }
                else
                {
                    //insert
                    CameraInfo camera = new CameraInfo();
                    string     cid    = ConfigurationHelper.GetConfig(ConfigItemName.clientId.ToString());
                    condition = CameraInfoEnum.client_id.ToString() + "=" + Constract.valueSplit + cid + Constract.valueSplit + " and " +
                                CameraInfoEnum.ip.ToString() + "=" + Constract.valueSplit + IpTB.Text.ToString() + Constract.valueSplit +
                                " and " + CameraInfoEnum.port.ToString() + "=" + Constract.valueSplit + this.portTB.Text.ToString() + Constract.valueSplit;
                    sql = DatabaseOPtionHelper.GetInstance().getSelectSqlNoSoftDeleteCondition(DatabaseOPtionHelper.GetInstance().getTableName(camera), null, condition, null, null, null, 1, 0);
                    SqlDao.DbHelper   optionHelper = DatabaseOPtionHelper.GetInstance();
                    List <CameraInfo> list         = optionHelper.select <CameraInfo>(sql);
                    if (list.Count > 0)
                    {
                        MessageBox.Show("该摄像头已经存在,不要再添加拉!");
                        return;
                    }
                    else
                    {
                        camera.clientId  = cid;
                        camera.companyId = ConfigurationHelper.GetConfig(ConfigItemName.companyId.ToString());
                        camera.status    = 0;
                        camera.isDelete  = 0;
                        camera.syncTime  = 0;
                        camera.ip        = this.IpTB.Text.Trim();
                        camera.port      = this.portTB.Text.Trim();
                        camera.userName  = this.userNameTB.Text.Trim();
                        camera.password  = this.pwdTB.Text.Trim();
                        camera.id        = Guid.NewGuid().ToString();
                        int res = optionHelper.insert(camera);
                        if (res > 0)
                        {
                            MessageBox.Show("保存成功!");
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("保存失败!");
                            return;
                        }
                    }
                }
            }
        }
Esempio n. 6
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;
                }
            }
        }