Beispiel #1
0
 private void dgvMain_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     try
     {
         if (isRequest)
         {
             statusMain.Invoke(new MethodInvoker(delegate
             {
                 lbOperation.Text = "Waiting reponse...";
             }));
             return;
         }
         if (isFilter)
         {
             statusMain.Invoke(new MethodInvoker(delegate
             {
                 lbOperation.Text = "Waiting filter...";
             }));
             return;
         }
         if (data == null || data.IsSuccessed == false || data.ResultObj == null || data.ResultObj.Items.Count == 0)
         {
             return;
         }
         if (dgvMain.Rows.Count > 0)
         {
             string id = (string)dgvMain.CurrentRow.Cells["Id"].Value;
             CurrenObject = data.ResultObj.Items.Where(s => s.Id == id).FirstOrDefault();
             if (CurrenObject == null)
             {
                 MessageBox.Show("Eror: recode is null");
                 return;
             }
             TypeFixParameter typeFixParameter = new TypeFixParameter();
             if (cboTypeFixParameter.Text == "All" || cboTypeFixParameter.Text == "IpWorkRoleToE")
             {
                 typeFixParameter = TypeFixParameter.IpWorkRoleToE;
             }
             else if (cboTypeFixParameter.Text == "MatchingReplateTitle")
             {
                 typeFixParameter = TypeFixParameter.MatchingReplateTitle;
             }
             else if (cboTypeFixParameter.Text == "MatchingReplateWriter")
             {
                 typeFixParameter = TypeFixParameter.MatchingReplateWriter;
             }
             else if (cboTypeFixParameter.Text == "NonMemberToMember")
             {
                 typeFixParameter = TypeFixParameter.NonMemberToMember;
             }
             frmFixParameterUpdate frm = new frmFixParameterUpdate(controller, UpdataType.View, CurrenObject, typeFixParameter);
             frm.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Beispiel #2
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         if (isRequest)
         {
             statusMain.Invoke(new MethodInvoker(delegate
             {
                 lbOperation.Text = "Waiting reponse...";
             }));
             return;
         }
         if (isFilter)
         {
             statusMain.Invoke(new MethodInvoker(delegate
             {
                 lbOperation.Text = "Waiting filter...";
             }));
             return;
         }
         if (data == null || data.IsSuccessed == false || data.ResultObj == null || data.ResultObj.Items.Count == 0)
         {
             return;
         }
         string id    = string.Empty;
         int    count = 0;
         for (int i = 0; i < dgvMain.Rows.Count; i++)
         {
             if (dgvMain.Rows[i].Cells[0].Value != null && (bool)dgvMain.Rows[i].Cells[0].Value == true)
             {
                 count++;
                 id = (string)dgvMain.Rows[i].Cells["Id"].Value;
                 if (count > 1)
                 {
                     MessageBox.Show("Please choise only one record!");
                     return;
                 }
             }
         }
         if (id == string.Empty)
         {
             MessageBox.Show("Please must choise one record!");
             return;
         }
         CurrenObject = data.ResultObj.Items.Where(s => s.Id == id).First();
         if (CurrenObject == null)
         {
             MessageBox.Show("Eror: recode is null");
             return;
         }
         TypeFixParameter typeFixParameter = new TypeFixParameter();
         if (cboTypeFixParameter.Text == "All" || cboTypeFixParameter.Text == "IpWorkRoleToE")
         {
             typeFixParameter = TypeFixParameter.IpWorkRoleToE;
         }
         else if (cboTypeFixParameter.Text == "MatchingReplateTitle")
         {
             typeFixParameter = TypeFixParameter.MatchingReplateTitle;
         }
         else if (cboTypeFixParameter.Text == "MatchingReplateWriter")
         {
             typeFixParameter = TypeFixParameter.MatchingReplateWriter;
         }
         else if (cboTypeFixParameter.Text == "NonMemberToMember")
         {
             typeFixParameter = TypeFixParameter.NonMemberToMember;
         }
         frmFixParameterUpdate frm = new frmFixParameterUpdate(controller, UpdataType.Edit, CurrenObject, typeFixParameter);
         frm.ShowDialog();
         if (frm.ObjectReturn != null && frm.ObjectReturn.Status == Utilities.Common.UpdateStatus.Successfull)
         {
             lbOperation.Text = $"Edited Item: {frm.ObjectReturn.Message}, total Edited: {frm.ObjectReturn.TotalEffect}";
             #region set backgroundFixParameterer
             Operation        = OperationType.GetDataFromServer;
             pcloader.Visible = true;
             pcloader.Dock    = DockStyle.Fill;
             backgroundWorker.RunWorkerAsync();
             #endregion
         }
         else
         {
             if (frm.ObjectReturn != null)
             {
                 lbOperation.Text = $"Edited Item: {frm.ObjectReturn.Message}";
             }
             else
             {
                 lbOperation.Text = $"Edited Item is failure";
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.ToString());
     }
 }
Beispiel #3
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (isRequest)
         {
             statusMain.Invoke(new MethodInvoker(delegate
             {
                 lbOperation.Text = "Waiting reponse...";
             }));
             return;
         }
         if (isFilter)
         {
             statusMain.Invoke(new MethodInvoker(delegate
             {
                 lbOperation.Text = "Waiting filter...";
             }));
             return;
         }
         TypeFixParameter typeFixParameter = new TypeFixParameter();
         if (cboTypeFixParameter.Text == "All" || cboTypeFixParameter.Text == "IpWorkRoleToE")
         {
             typeFixParameter = TypeFixParameter.IpWorkRoleToE;
         }
         else if (cboTypeFixParameter.Text == "MatchingReplateTitle")
         {
             typeFixParameter = TypeFixParameter.MatchingReplateTitle;
         }
         else if (cboTypeFixParameter.Text == "MatchingReplateWriter")
         {
             typeFixParameter = TypeFixParameter.MatchingReplateWriter;
         }
         else if (cboTypeFixParameter.Text == "NonMemberToMember")
         {
             typeFixParameter = TypeFixParameter.NonMemberToMember;
         }
         CurrenObject = new FixParameterViewModel();
         frmFixParameterUpdate frm = new frmFixParameterUpdate(controller, UpdataType.Add, CurrenObject, typeFixParameter);
         frm.ShowDialog();
         if (frm.ObjectReturn != null && frm.ObjectReturn.Status == Utilities.Common.UpdateStatus.Successfull)
         {
             lbOperation.Text = $"Added Item: {frm.ObjectReturn.Message}, total Added: {frm.ObjectReturn.TotalEffect}";
             #region set backgroundFixParameterer
             Operation        = OperationType.GetDataFromServer;
             pcloader.Visible = true;
             pcloader.Dock    = DockStyle.Fill;
             backgroundWorker.RunWorkerAsync();
             #endregion
         }
         else
         {
             if (frm.ObjectReturn != null)
             {
                 lbOperation.Text = $"Added Item: {frm.ObjectReturn.Message}";
             }
             else
             {
                 lbOperation.Text = $"Added Item is failure";
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.ToString());
     }
 }