Esempio n. 1
0
        private void btnGroupAdd_Click(object sender, EventArgs e)
        {
            if (groupMode != OperationType.Add)
            {
                groupMode              = OperationType.Add;
                btnCancel.Visible      = true;
                btnGroupAdd.Text       = "Lưu";
                btnGroupEdit.Visible   = false;
                btnGroupDelete.Visible = false;

                tbGroupName.Enabled       = true;
                cbGroupTour.Enabled       = true;
                dtpGroupStartDate.Enabled = true;
                dtpGroupEndDate.Enabled   = true;
            }
            else
            {
                var      name      = tbGroupName.Text;
                int      tourId    = (int)cbGroupTour.SelectedValue;
                DateTime startDate = dtpGroupStartDate.Value;
                DateTime endDate   = dtpGroupEndDate.Value;
                try
                {
                    GroupBLL.CreateGroup(name, startDate, endDate, tourId);
                    Thread loadGroupsThread = new Thread(() => LoadGroups());
                    loadGroupsThread.Start();
                    MessageBox.Show("Thêm thành công");
                }
                catch (Exception ex)
                {
                    string message = "";
                    foreach (DictionaryEntry item in ex.Data)
                    {
                        message += item.Value?.ToString();
                        message += Environment.NewLine;
                    }
                    MessageBox.Show(message);
                    return;
                }

                groupMode              = OperationType.View;
                btnGroupAdd.Text       = "+ Thêm";
                btnGroupEdit.Visible   = true;
                btnGroupDelete.Visible = true;
                btnCancel.Visible      = false;

                tbGroupName.Enabled       = false;
                cbGroupTour.Enabled       = false;
                dtpGroupStartDate.Enabled = false;
                dtpGroupEndDate.Enabled   = false;
            }

            dgvGroupList.ClearSelection();
        }
Esempio n. 2
0
 /// <summary>
 /// 新建群组  修改群组
 /// </summary>
 /// <param name="session">session</param>
 /// <param name="groupName">群组名称</param>
 /// <param name="Introduce">群组简介</param>
 /// <param name="isOpen">1公开或0私密</param>
 /// <param name="groupID">群组ID 0添加  大于0修改</param>
 /// <returns></returns>
 public Stream CreateGroup(string session, string groupName, string introduce, string isOpen, string groupID)
 {
     try
     {
         GroupBLL groupBLL = new GroupBLL();
         string   resul    = groupBLL.CreateGroup(session, groupName, introduce, isOpen, groupID);
         if (!string.IsNullOrEmpty(resul))
         {
             return(new MemoryStream(Encoding.UTF8.GetBytes(resul)));
         }
         else
         {
             return(new MemoryStream(Encoding.UTF8.GetBytes("error")));
         }
     }
     catch (Exception err)
     {
         Logger.Error("CreateGroup Error", err);
         return(new MemoryStream(Encoding.UTF8.GetBytes("error")));
     }
 }