示例#1
0
 public void ClearValues(bool PK = false)
 {
     //setRSPosition(0);
     if (PK)
     {
         CTLMItems.Where(r => r.PK == false).ToList().ForEach(i => {
             i.ClearEspackControl();
         });
     }
     else
     {
         CTLMItems.ForEach(i => {
             i.ClearEspackControl();
         });
     }
     if (MsgStatusInfoLabel != null)
     {
         MsgStatusInfoLabel.Text = "";
     }
 }
示例#2
0
        public void Button_Click(string pButtonName) //lauched when clicked any button
        {
            try
            {
                CTLMEventArgs lCTLMEventArgs = new CTLMEventArgs(pButtonName);
                OnBeforeButtonClick(lCTLMEventArgs); //launched BeforeButtonClick Event
                if (lCTLMEventArgs.Cancel)
                {
                    return;
                }
                switch (pButtonName)
                {
                case "btnAdd":
                    OnAfterButtonClick(new CTLMEventArgs(pButtonName));     //Launched AfterButtonClick Event
                    SetStatus(EnumStatus.ADDNEW);
                    CTLMItems.Where(x => x.DefaultValue != null).ToList().ForEach(x => x.Value = x.DefaultValue);
                    break;

                case "btnUpp":
                    OnAfterButtonClick(new CTLMEventArgs(pButtonName));     //Launched AfterButtonClick Event
                    SetStatus(EnumStatus.EDIT);
                    break;

                case "btnDel":
                    if (MessageBox.Show("This will delete the actual record. Are you sure?", "WARNING", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        SetStatus(EnumStatus.DELETE);
                        Click_OK(pButtonName);
                    }
                    break;

                case "btnSearch":
                    OnAfterButtonClick(new CTLMEventArgs(pButtonName));
                    SetStatus(EnumStatus.SEARCH);
                    break;

                case "btnCancel":
                    ClearValues();
                    OnAfterButtonClick(new CTLMEventArgs(pButtonName));
                    SetStatus(EnumStatus.SEARCH);
                    break;

                case "btnOk":
                    Click_OK(pButtonName);
                    break;

                case "btnNext":
                    if (mDA.SelectRS.State == RSState.Open)
                    {
                        try
                        {
                            setRSPosition(RSPosition + 1);
                        } catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    OnAfterButtonClick(new CTLMEventArgs(pButtonName));
                    break;

                case "btnPrev":
                    if (mDA.SelectRS.State == RSState.Open)
                    {
                        try
                        {
                            setRSPosition(RSPosition - 1);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    OnAfterButtonClick(new CTLMEventArgs(pButtonName));
                    break;

                case "btnFirst":
                    if (mDA.SelectRS.State == RSState.Open)
                    {
                        try
                        {
                            setRSPosition(0);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    OnAfterButtonClick(new CTLMEventArgs(pButtonName));
                    break;

                case "btnLast":
                    if (mDA.SelectRS.State == RSState.Open)
                    {
                        try
                        {
                            setRSPosition(mDA.SelectRS.RecordCount - 1);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    OnAfterButtonClick(new CTLMEventArgs(pButtonName));
                    break;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }