Esempio n. 1
0
        private void SaveNewItem()
        {
            if (radioButtonCELLEX.Checked == false)
            {
                if (radioButtonMEDEX.Checked == false)
                {
                    Messaging.ShowInfoMessageBox("You must select either MEDEX or CELLEX ");
                    return;
                }
            }

            if (radioButtonCELLEX.Checked == false && radioButtonMEDEX.Checked == false)
            {
                Messaging.ShowInfoMessageBox("You must select either MEDEX or CELLEX ");
                return;
            }
            else
            {
                if (comboBoxCellexTypes.SelectedIndex == -1)
                {
                    if (comboBoxMedexTypes.SelectedIndex == -1)
                    {
                        Messaging.ShowInfoMessageBox("You must select either MEDEX or CELLEX type.");
                        return;
                    }
                }
            }

            if (comboBoxCellexTypes.SelectedIndex > -1)
            {
                if (comboBoxCellexTypes.SelectedItem.ToString() == "Other" && textBoxCellexOther.Text == string.Empty)
                {
                    Messaging.ShowInfoMessageBox("If you select other you must put a value in the other box.");
                    return;
                }
            }

            if (comboBoxMedexTypes.SelectedIndex > -1)
            {
                if (comboBoxMedexTypes.SelectedItem.ToString() == "Other" && textBoxMedexOther.Text == string.Empty)
                {
                    Messaging.ShowInfoMessageBox("If you select other you must put a value in the other box.");
                    return;
                }
            }

            if (!string.IsNullOrEmpty(textBoxSize.Text) && comboBoxSizes.SelectedIndex < 0)
            {
                Messaging.ShowInfoMessageBox("If you enter a size you must select a size type.");
                return;
            }

            if (this.checkBoxSubItem.Checked == true && comboBoxExistingItems.SelectedIndex < 0)
            {
                Messaging.ShowInfoMessageBox("If you enter select sub item you must select a case from the drop down.");
                return;
            }

            Item item = new Item();

            if (comboBoxExistingItems.SelectedIndex > -1)
            {
                item.Parent_ID = GetCaseId();
            }

            if (radioButtonMEDEX.Checked == true)
            {
                item.isMedex = 1;
                if (comboBoxMedexTypes.SelectedIndex > -1)
                {
                    if (comboBoxMedexTypes.SelectedItem.ToString() == "Other")
                    {
                        item.Type = textBoxMedexOther.Text;
                    }
                    else
                    {
                        item.Type = comboBoxMedexTypes.SelectedItem.ToString();
                    }
                }
            }

            if (radioButtonCELLEX.Checked == true)
            {
                item.isMobile = 1;

                if (comboBoxCellexTypes.SelectedIndex > -1)
                {
                    if (comboBoxCellexTypes.SelectedItem.ToString() == "Other")
                    {
                        item.Type = textBoxCellexOther.Text;
                    }
                    else
                    {
                        item.Type = comboBoxCellexTypes.SelectedItem.ToString();
                    }
                }
            }

            if (comboBoxCellexTypes.SelectedIndex > -1)
            {
                if (comboBoxCellexTypes.SelectedItem.ToString() == "SIM")
                {
                    item.Type  = "SIM";
                    item.isSim = 1;
                }
            }

            item.CaseNumber = GetCaseId();

            if (comboBoxSizes.SelectedIndex > -1)
            {
                item.SizeType_ID = GetSizeId();
            }

            item.Size              = textBoxSize.Text.ToString();
            item.Make              = textBoxMake.Text.Trim();
            item.Comments          = tbComments.Text.Trim();
            item.ICCID             = textBoxICCID.Text.Trim();
            item.IMEI              = textBoxIMEI.Text.Trim();
            item.IMSI              = textBoxIMSI.Text.Trim();
            item.SerialNumber      = textBoxSerial.Text.Trim();
            item.SubmittedDate     = DateTime.Now.ToShortDateString();
            item.UpdatedDate       = DateTime.Now.ToShortDateString();
            item.SubscriberAccount = textBoxSubscriberAccount.Text.Trim();
            item.ClosedDate        = "1900-01-01";
            item.Model             = textBoxModel.Text.Trim();
            item.isSent            = 0;
            item.isOpen            = 1;
            item.Zipped            = 0;
            item.isSubItem         = checkBoxSubItem.Checked == true ? 1 : 0;

            if (item.isSubItem == 1)
            {
            }

            item.Parent_ID = GetCaseId();

            SaveNewItem(item);
        }
Esempio n. 2
0
        private double GetItemNumber(Item item)
        {
            double itemNum = 0;
            string caseFolder;

            DataTable dataTable1 = Database.Get.CaseFolder();

            if (dataTable1.Rows.Count < 1)
            {
                Messaging.ShowInfoMessageBox("Case folder not found.");
                return(-1);
            }

            caseFolder = dataTable1.Rows[0].Field <string>("location");

            List <double> decimalList = new List <double>();
            GFG           gg          = new GFG();

            string fullPath = Path.Combine(caseFolder, _case_name, "DOMEX");

            string[] items = Directory.GetDirectories(fullPath);

            if (item.isSubItem == 1)
            {
                if (!string.IsNullOrEmpty(_case_name))
                {
                    CheckParent(item);
                    DataTable dataTable = Database.Get.Items(item.Parent_ID);
                    if (dataTable.Rows.Count < 1)
                    {
                        Messaging.ShowInfoMessageBox("Subitem parent not found");
                        return(-1);
                    }

                    string[] splitName  = dataTable.Rows[0].Field <string>("folder_name").ToString().Split('_');
                    string   primaryNum = splitName[0].Substring(0, 1);

                    itemNum = Convert.ToDouble(splitName[0]);

                    foreach (string folder in items)
                    {
                        string[] path       = folder.Split('\\');
                        string   dirName    = path[path.Length - 1];
                        string[] splitName2 = dirName.Split('_');

                        if (splitName2[0].ToString().Substring(0, 1) == primaryNum)
                        {
                            if (splitName2[0].ToString().Contains("."))
                            {
                                decimalList.Add(Convert.ToDouble(splitName2[0]) + .1);
                            }
                        }
                    }

                    //no sub items were created yet
                    if (decimalList.Count < 1)
                    {
                        decimalList.Add(Convert.ToDouble(primaryNum) + .1);
                    }

                    decimalList.Sort(gg);

                    itemNum = decimalList[decimalList.Count - 1];

                    decimalList.Clear();
                }
            }
            else
            {
                foreach (string folder in items)
                {
                    string[] path      = folder.Split('\\');
                    string   dirName   = path[path.Length - 1];
                    string[] splitName = dirName.Split('_');
                    itemNum = Convert.ToDouble(splitName[0]);

                    if (!splitName[0].Contains("."))
                    {
                        decimalList.Add(itemNum);
                    }
                }
                decimalList.Sort(gg);

                if (decimalList.Count > 0)
                {
                    itemNum = decimalList[decimalList.Count - 1] + 1;
                }
                decimalList.Clear();
            }

            if (itemNum == 0)
            {
                itemNum = 1;
            }

            return(itemNum);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        private void SaveNewItem(Item item)
        {
            double itemNum   = GetItemNumber(item);
            string case_name = GetCaseName();

            if (itemNum > 0)
            {
                string itemMake  = CleanName(item.Make.Trim());
                string itemModel = CleanName(item.Model.Trim());
                string itemType  = CleanName(item.Type.Trim());
                string itemSize  = CleanName(item.Size.Trim());
                string itemSerNo = CleanName(item.SerialNumber.Trim());

                string folderName = itemNum + "_" + itemMake + "_" + itemModel + "_" + itemType + "_" + itemSize + "_" + itemSerNo;
                item.folderName = folderName;


                item.SubmittedDate = DateTime.Now.ToString("s");
                string newItemDirectory = _CasePath + @"\" + case_name + @"\DOMEX\" + folderName;

                int case_num = GetCaseId();

                Database.Insert.CaseItem(case_num, item.Make, item.Model, item.Size, item.SizeType_ID, item.SerialNumber, item.IMEI, item.ICCID, item.IMSI
                                         , item.SubscriberAccount, item.Comments, 0, 0, 1, item.ClosedDate, item.UpdatedDate, item.SubmittedDate, item.Type
                                         , item.isMedex, item.isMobile, item.isSim, item.isSubItem, item.Parent_ID, item.folderName);

                if (Directory.Exists(newItemDirectory))
                {
                    Messaging.ShowInfoMessageBox("Directory already exists, please rename.");
                    return;
                }
                else
                {
                    Directory.CreateDirectory(newItemDirectory);
                }

                if (item.isMedex == 1)
                {
                    CreateMedexFolders(newItemDirectory);
                }

                if (item.isMobile == 1)
                {
                    if (item.isSim == 1)
                    {
                        CreateSimFolders(newItemDirectory);
                    }
                    else
                    {
                        CreateMobileFolders(newItemDirectory);
                    }
                }

                textBoxSize.Text                  = string.Empty;
                textBoxCellexOther.Text           = string.Empty;
                textBoxMedexOther.Text            = string.Empty;
                textBoxSerial.Text                = string.Empty;
                checkBoxSubItem.Checked           = false;
                radioButtonCELLEX.Checked         = false;
                radioButtonMEDEX.Checked          = false;
                comboBoxCellexTypes.SelectedIndex = -1;
                comboBoxMedexTypes.SelectedIndex  = -1;
                comboBoxSizes.SelectedIndex       = -1;
            }
        }
Esempio n. 4
0
        private void SaveCase()
        {
            if (ComboBoxAor.SelectedIndex < 0)
            {
                Messaging.ShowInfoMessageBox("You must select an AOR.");
                return;
            }

            if (ComboBoxClassification.SelectedIndex < 0)
            {
                Messaging.ShowInfoMessageBox("You must select a classification.");
                return;
            }

            DT3Case item = new DT3Case();

            item.AOR_ID            = GetAorId(ComboBoxAor.SelectedItem.ToString().Trim());
            item.CaseNumber        = textBoxCaseId.Text.Trim();
            item.Classification_ID = GetClassificationId(ComboBoxClassification.SelectedItem.ToString().Trim());
            item.Comments          = TextBoxComments.Text.Trim();
            item.SubmittedDate     = DateTime.Now.ToShortDateString().Trim();
            item.MGRS           = TextBoxMgrs.Text.Trim();
            item.Objective      = TextBoxObjective.Text.Trim();
            item.SubmitterEmail = TextBoxSubmitterEmail.Text.Trim();
            item.SubmitterName  = TextBoxSubmitterName.Text.Trim();
            item.UpdatedDate    = DateTime.Now.ToShortDateString().Trim();
            item.SubjectName    = TextBoxSubjectName.Text.Trim();
            item.Open           = 1;
            item.Sent           = 0;
            item.Zipped         = 0;

            try
            {
                Database.Insert.Case(item.CaseNumber, item.MGRS, item.Objective,
                                     item.SubjectName, item.AOR_ID, item.Classification_ID,
                                     item.SubmitterName, item.SubmitterEmail, item.Comments);

                string folderPath = Path.Combine(_CasePath, item.CaseNumber);
                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                    WriteCaseFolders(folderPath);
                }
                else
                {
                    Messaging.ShowInfoMessageBox("Case already exists, please change the name and try again.");
                }
            }
            catch
            {
            }

            ComboBoxAor.SelectedIndex            = -1;
            ComboBoxClassification.SelectedIndex = -1;
            TextBoxComments.Text       = string.Empty;
            TextBoxMgrs.Text           = string.Empty;
            TextBoxObjective.Text      = string.Empty;
            TextBoxSubmitterEmail.Text = string.Empty;
            TextBoxSubmitterName.Text  = string.Empty;
            textBoxCaseId.Text         = string.Empty;
            TextBoxSubjectName.Text    = string.Empty;
            this.Close();
        }