Ejemplo n.º 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());
     }
 }
Ejemplo n.º 2
0
 public frmFixParameterUpdate(FixParameterController Controller, UpdataType view, FixParameterViewModel currenObject, TypeFixParameter typeFixParameter)
 {
     InitializeComponent();
     this._Controller       = Controller;
     this._updataType       = view;
     this.currenObject      = currenObject;
     this._typeFixParameter = typeFixParameter;
     //this._group = Group;
 }
Ejemplo n.º 3
0
        private void LoadFrom()
        {
            if (_updataType == UpdataType.Edit || _updataType == UpdataType.View)
            {
                if (_updataType == UpdataType.Edit)
                {
                    this.Text = "Update Fix Parameter";
                }
                else
                {
                    this.Text = "View Fix Parameter";
                }
                if (_group == 0)
                {
                    this.Text += "-WORK";
                }
                else
                {
                    this.Text += "-MEMBER";
                }
                if (currenObject == null)
                {
                    return;
                }
                cboType.Text    = currenObject.Type;
                txtKey.Text     = currenObject.Key;
                txtValue1.Text  = currenObject.Value1;
                txtValue2.Text  = currenObject.Value2;
                txtValue3.Text  = currenObject.Value3;
                txtValue4.Text  = currenObject.Value4;
                txtValue5.Text  = currenObject.Value5;
                txtValue6.Text  = currenObject.Value6;
                txtValue7.Text  = currenObject.Value7;
                txtValue8.Text  = currenObject.Value8;
                txtValue9.Text  = currenObject.Value9;
                txtValue10.Text = currenObject.Value10;


                if (_updataType == UpdataType.Edit)
                {
                    cboType.Enabled = false;
                    txtKey.ReadOnly = true;
                }
                else
                {
                    //txtNo.ReadOnly = true;
                    cboType.Enabled    = false;
                    txtKey.ReadOnly    = true;
                    txtValue1.ReadOnly = true;
                    txtValue2.ReadOnly = true;
                    txtValue3.ReadOnly = true;

                    txtValue4.ReadOnly  = true;
                    txtValue5.ReadOnly  = true;
                    txtValue6.ReadOnly  = true;
                    txtValue7.ReadOnly  = true;
                    txtValue8.ReadOnly  = true;
                    txtValue9.ReadOnly  = true;
                    txtValue10.ReadOnly = true;
                    btnOk.Enabled       = false;
                }
            }
            else if (_updataType == UpdataType.Add)
            {
                this.Text    = "Add Fix Parameter";
                cboType.Text = _typeFixParameter.ToString();
                currenObject = new FixParameterViewModel();
            }
        }
Ejemplo n.º 4
0
        private async void btnDelete_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    = "";
                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;
                }
                var confirmResult = MessageBox.Show("Are you sure to delete this record?",
                                                    "Confirm Delete!!",
                                                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    var deleteStatus = await controller.Delete(CurrenObject.Id);

                    if (deleteStatus != null && deleteStatus.Status == Utilities.Common.UpdateStatus.Successfull)
                    {
                        lbOperation.Text = $"Deleted record: {deleteStatus.Message}, total Deleted: {deleteStatus.TotalEffect}";
                        #region set backgroundFixParameterer
                        Operation        = OperationType.GetDataFromServer;
                        pcloader.Visible = true;
                        pcloader.Dock    = DockStyle.Fill;
                        backgroundWorker.RunWorkerAsync();
                        #endregion
                    }
                    else
                    {
                        if (deleteStatus != null)
                        {
                            lbOperation.Text = $"Deleted Item: {deleteStatus.Message}";
                        }
                        else
                        {
                            lbOperation.Text = $"Deleted Item is failure";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
        }
Ejemplo n.º 5
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());
     }
 }
Ejemplo n.º 6
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());
     }
 }