コード例 #1
0
ファイル: MainForm.cs プロジェクト: iluxa1810/DictService
        private void editDictButton_Click(object sender, EventArgs e)
        {
            if (dgvDict.SelectedCells[dgvDict.Columns["State"].Index].Value.ToString() != DictionaryStateEnum.Available.ToString())
            {
                MessageBox.Show("Сейчас словарь нельзя редактировать");
                return;
            }
            var dictId       = dgvDict.SelectedCells[dgvDict.Columns["Dictionary_id"].Index].Value.ToString();
            var dictName     = dgvDict.SelectedCells[dgvDict.Columns["FriendlyName"].Index].Value.ToString();
            var categoryName = dgvDict.SelectedCells[dgvDict.Columns["CategoryName"].Index].Value.ToString();
            var description  = dgvDict.SelectedCells[dgvDict.Columns["Description"].Index].Value.ToString();

            using (var form = new EditDictionaryForm(dictId, dictName, categoryName, description))
            {
                using (var client = new DataClient())
                {
                    client.ChangeDictionaryStatus(Convert.ToInt32(dictId), DictionaryStateEnum.Locked);
                }
                form.Owner = this;
                form.ShowDialog();
            }
        }
コード例 #2
0
 private async void resfreshBtn_Click(object sender, EventArgs e)
 {
     if (uploadChkBx.Checked)
     {
         using (var client = new FileUploadClient())
         {
             try
             {
                 string path;
                 path = ZipHelper.CreateZipDictionary(tbFilePath.Text);
                 DictionaryInfo dictInfo = new DictionaryInfo()
                 {
                     Dictionary_id = Convert.ToInt32(tbDictionaryId.Text)
                     , SenderLogin = AccountHelper.GetAccount(), Action = ActionEnum.EditDict
                 };
                 Stream file = new FileStream(path, FileMode.Open);
                 await client.UploadAsync(dictInfo, file);
             }
             catch (Exception)
             {
             }
         }
     }
     using (var client = new DataClient())
     {
         var dictInfo = new DictionaryData()
         {
             Dictionary_id = Convert.ToInt32(tbDictionaryId.Text),
             Category_id   = ((CategoryData)categoryCb.SelectedItem).Category_id,
             FriendlyName  = FrendlyNameTb.Text,
             Description   = DescriptionRtb.Text
         };
         client.ChangeDictionaryInfo(dictInfo);
         client.ChangeDictionaryStatus(Convert.ToInt32(tbDictionaryId.Text), DictionaryStateEnum.Available);
     }
 }