示例#1
0
文件: Main.cs 项目: ixrwang/redmine
 void btn_ok_Click(object sender, EventArgs e)
 {
     ComboBox cb_project = (ComboBox)panel_context.Controls["cb_project"];
     DateTimePicker dtp_time = (DateTimePicker)panel_context.Controls["dtp_time"];
     ComboBox cb_activity = (ComboBox)panel_context.Controls["cb_activity"];
     MaskedTextBox mtb_time = (MaskedTextBox)panel_context.Controls["mtb_time"];
     TextBox tb_context = (TextBox)panel_context.Controls["tb_context"];
     TimeEntries timet_entries = new TimeEntries();
     timet_entries.project_id = cb_project.SelectedValue.ToString();
     timet_entries.spent_on = dtp_time.Text;
     timet_entries.activity_id = cb_activity.SelectedValue.ToString();
     timet_entries.hours = mtb_time.Text;
     if (".".Equals(timet_entries.hours))
     {
         MessageBox.Show("请填写工时!");
         return;
     }
     else if (timet_entries.hours.EndsWith("."))
     {
         timet_entries.hours = timet_entries.hours.Substring(0, timet_entries.hours.Length - 1);
     }
     timet_entries.comments = tb_context.Text;
     try
     {
         service.timet_entries(timet_entries);
         MessageBox.Show("打卡成功!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#2
0
 public string timet_entries(TimeEntries timet_entries)
 {
     WebClient client = newWebClient();
     client.Encoding = System.Text.Encoding.UTF8;
     NameValueCollection param = new NameValueCollection();
     param.Add("time_entry[issue_id]", timet_entries.issue_id);
     param.Add("time_entry[project_id]", timet_entries.project_id);
     param.Add("time_entry[spent_on]", timet_entries.spent_on);
     param.Add("time_entry[hours]", timet_entries.hours);
     param.Add("time_entry[activity_id]", timet_entries.activity_id);
     param.Add("time_entry[comments]", timet_entries.comments);
     byte[] bytes = client.UploadValues(string.Format("{0}/time_entries.xml", domain), param);
     XmlDocument xml = new XmlDocument();
     xml.LoadXml(UTF8Encoding.UTF8.GetString(bytes));
     XmlNode node = xml.SelectSingleNode("time_entry/id");
     return node.InnerText;
 }