コード例 #1
0
        private void UC_DiaryCell_Click(object sender, EventArgs e)
        {
            //跳转至日志详情页面
            string         id             = this.DiaryId;
            UC_DiaryDetail uc_DiaryDetail = new UC_DiaryDetail(id, this.ChangePanel);

            this.ChangePanel(uc_DiaryDetail);
        }
コード例 #2
0
        private void UC_LogCell_Click(object sender, EventArgs e)
        {
            //跳转到日志的详情界面
            string id = this.DiaryId;

            using (UC_DiaryDetail uc_DiaryDetail = new UC_DiaryDetail(id))
            {
                this.ChangePanel(uc_DiaryDetail);
            }
        }
コード例 #3
0
        private async void BtnAddDiary_Click(object sender, EventArgs e)
        {
            //添加日志
            string        url           = "https://localhost:5001/api/diary";
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(Diary));
            Client        client        = new Client();

            try
            {
                string data  = "";
                Diary  diary = new Diary();
                diary.DiaryId = 0; //后端会重新赋值,此处值不重要
                diary.Time    = DateTime.Now;
                diary.Share   = 0; //默认不分享
                diary.Uid     = Convert.ToInt32(this.Uid);

                using (StringWriter sw = new StringWriter())
                {
                    xmlSerializer.Serialize(sw, diary);
                    data = sw.ToString();
                }
                HttpResponseMessage result = await client.Post(url, data);

                if (result.IsSuccessStatusCode)
                {
                    diary = (Diary)xmlSerializer.Deserialize(await result.Content.ReadAsStreamAsync());
                    //跳转至编辑日志界面
                    using (UC_DiaryDetail uc_DiaryDetail = new UC_DiaryDetail(diary.DiaryId.ToString(), ChangePanel))
                    {
                        this.ChangePanel(uc_DiaryDetail);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }