Exemple #1
0
 private void listServiceGroup(int lvl)
 {
     try
     {
         grdList.Rows.Clear();
         ServiceGroupDB      sgdb   = new ServiceGroupDB();
         List <servicegroup> sgroup = sgdb.getServiceGroupDetails(lvl);
         int i = 1;
         foreach (servicegroup sg in sgroup)
         {
             grdList.Rows.Add();
             grdList.Rows[grdList.RowCount - 1].Cells["LineNo"].Value           = i;
             grdList.Rows[grdList.RowCount - 1].Cells["GroupCode"].Value        = sg.GroupCode;
             grdList.Rows[grdList.RowCount - 1].Cells["GroupDescription"].Value = sg.GroupDescription;
             grdList.Rows[grdList.RowCount - 1].Cells["CreateTime"].Value       = sg.CreateTime;
             grdList.Rows[grdList.RowCount - 1].Cells["Creator"].Value          = sg.CreateUser;
             i++;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in Service Group  Listing");
     }
     try
     {
         enableBottomButtons();
         pnlList.Visible = true;
         btnNew.Visible  = false;
     }
     catch (Exception ex)
     {
     }
 }
Exemple #2
0
        public string getGroupCode()
        {
            string gc = "";

            ServiceGroupDB      sdb     = new ServiceGroupDB();
            List <servicegroup> LSGroup = sdb.getServiceGroupDetails(lvl);
            SortedSet <string>  set     = new SortedSet <string>();

            try
            {
                foreach (servicegroup sg in LSGroup)
                {
                    set.Add(sg.GroupCode);
                }
                gc = set.Max;
            }
            catch (Exception ex)
            {
            }
            if (Convert.ToInt32(gc) == 0)
            {
                gc = "10";// group coe start with 10
            }
            return((Convert.ToInt32(gc) + 1).ToString());
        }
Exemple #3
0
 private void initVariables()
 {
     try
     {
         if (getuserPrivilegeStatus() == 1)
         {
             //user is only a viewer
             listOption = 6;
         }
         ServiceGroupDB.fillGroupValueCombo(cmbGroup1Select, 1);
         ServiceGroupDB.fillGroupValueCombo(cmbGroup2Select, 2);
         ServiceGroupDB.fillGroupValueCombo(cmbGroup3Select, 3);
         //fillTypeCombo(cmbGroup);
         userString        = Login.userLoggedInName + Main.delimiter1 + Login.userLoggedIn + Main.delimiter1 + Main.delimiter2;
         lblStatus.Visible = false;
         cmbStatus.Visible = false;
         setButtonVisibility("init");
     }
     catch (Exception)
     {
     }
 }
Exemple #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Boolean status = true;

            try
            {
                ServiceGroupDB sgdb             = new ServiceGroupDB();
                servicegroup   sg               = new servicegroup();
                System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button;
                string btnText = btnSave.Text;

                try
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(txtGroupCode.Text, @"^[0-9]+$"))
                    {
                        MessageBox.Show("This GroupCode accepts only numeric characters");
                        return;
                    }
                    else
                    {
                        sg.GroupCode = txtGroupCode.Text;
                    }

                    //if (!System.Text.RegularExpressions.Regex.IsMatch(txtGroupDescription.Text, @"^[\sa-zA-Z0-9]+$"))
                    //{
                    //    MessageBox.Show("This GroupDescription accepts only alphanumeric characters");
                    //    return;
                    //}
                    //else

                    sg.GroupDescription = txtGroupDescription.Text.Trim().Replace("'", "''");

                    sg.GroupLevel = Convert.ToInt32(cmbSelectLevel.SelectedItem.ToString().Trim());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Validation failed");
                    return;
                }

                if (btnText.Equals("Save"))
                {
                    if (sgdb.validateServiceGroup(sg))
                    {
                        if (sgdb.insertServiceGroup(sg))
                        {
                            MessageBox.Show("Service Code Added");
                            closeAllPanels();
                            listServiceGroup(lvl);
                            pnlAddNew.Visible        = false;
                            pnlBottomButtons.Visible = true;
                        }
                        else
                        {
                            status = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Validation failed");
                    }
                    if (!status)
                    {
                        MessageBox.Show("Failed to Insert Service Group");
                    }
                }
                else if (btnText.Equals("update"))
                {
                    if (sgdb.validateServiceGroup(sg))
                    {
                        if (sgdb.updateServiceGroup(sg))
                        {
                            MessageBox.Show("service Code Added");
                            closeAllPanels();
                            listServiceGroup(lvl);
                            pnlAddNew.Visible        = false;
                            pnlBottomButtons.Visible = true;
                        }
                        else
                        {
                            status = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Validation failed");
                    }
                    if (!status)
                    {
                        MessageBox.Show("Failed to Insert Service Group");
                    }
                }
                else
                {
                    MessageBox.Show("btnSave error.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Errorr in saving");
            }
        }