Ejemplo n.º 1
0
        public static DialogResult Show(object h)
        {
            CstmMSG = new customMSG();
            CstmMSG.ComboCustom.DataSource = h;

            CstmMSG.ShowDialog();
            return(result);
        }
Ejemplo n.º 2
0
        public void panel2_DragDrop(object sender, DragEventArgs e)
        {
            string FolderColor(string num)
            {
                if (num == "16777215")
                {
                    return("SBD_White");
                }
                else if (num == "5296274")
                {
                    return("SBD_Green");
                }
                else if (num == "65535")
                {
                    return("SBD_Yellow");
                }
                else if (num == "255")
                {
                    return("SBD_Red");
                }
                else if (num == "192")
                {
                    return("SBD_Dark_Red");
                }
                else if (num == "49407")
                {
                    return("SBD_Orange");
                }
                else if (num == "5287936")
                {
                    return("SBD_Dark_Green");
                }
                else if (num == "15773696")
                {
                    return("SBD_Light_Blue");
                }
                else if (num == "12611584")
                {
                    return("SBD_Blue");
                }
                else if (num == "6299648")
                {
                    return("SBD_Dark_Blue");
                }
                else if (num == "10498160")
                {
                    return("SBD_Purple");
                }


                else
                {
                    var unknownColor = string.Concat("SBD_" + num);
                    MessageBox.Show("Custom color! Folder named: " + unknownColor);
                    return(unknownColor);
                }
            }

            if (xmlPath == null)
            {
                MessageBox.Show("Drag '10_XMLs_org' folder first");
                panel2.BackColor = Color.White;
            }
            else
            {
                string[] exclefile = (string[])e.Data.GetData(DataFormats.FileDrop, false);

                if (exclefile[0].IndexOf(".xlsx") == -1)
                {
                    MessageBox.Show("Must be an XLSX file");
                    panel2.BackColor = Color.White;
                }
                else
                {
                    panel2.BackColor = Color.Gray;
                    label7.Visible   = true;
                    // else

                    textBox3.Text  = exclefile[0];
                    label5.Enabled = false;


                    string fle = exclefile[0].ToString();
                    //MessageBox.Show(fle);
                    Excel excel = new Excel(fle);
                    //wyzej dodaj 2gi param ewentualnie
                    //MessageBox.Show(excel.ReadCell(13, 2));
                    // MessageBox.Show(excel.ReadColor(13, 2));
                    //MessageBox.Show(excel.Get1stRowLength().ToString());

                    int exlLeng = Int32.Parse(excel.Get1stRowLength());

                    for (int i = 1; i < exlLeng; i++)

                    {
                        //MessageBox.Show(excel.ReadCellNum(i, 1).ToString());
                        l.Add(excel.ReadCellNum(i, 1));
                    }

                    l = l.Distinct().ToList();
                    l.Remove(0);
                    //comboBox1.DataSource = l;

                    //customMSG.Show(l);
                    //MessageBox.Show("wybrano batch (ze zmiennej)" + BaczNumCustom);
                    int copyCounter = 0;

                    using (customMSG form22 = new customMSG())
                    {
                        form22.ComboCustom.DataSource = l;
                        if (form22.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            selekt = Convert.ToInt32(form22.ComboCustom.SelectedItem);
                            //MessageBox.Show("Batch: " + selekt);

                            double skan;
                            string curColor;
                            string procka;
                            string prockaSearch;
                            string SBD_Color;


                            DirectoryInfo D1     = Directory.CreateDirectory(xmlPath);
                            string        parent = Directory.GetParent(xmlPath).FullName;
                            //MessageBox.Show(parent);
                            DirectoryInfo D2 = Directory.CreateDirectory(parent);


                            for (int i = 1; i < exlLeng; i++)
                            {
                                skan = excel.ReadCellNum(i, 1);
                                if (skan != selekt)
                                {
                                    continue;
                                }
                                else
                                {
                                    //MessageBox.Show("batcz " + selekt + " wystepuje w komorce " + i + " procka: " + excel.ReadCell(i, 2) + " kolorek: " + excel.ReadColor(i, 2) + " w folderze " + xmlPath);
                                    curColor     = excel.ReadColor(i, 2);
                                    procka       = excel.ReadCell(i, 2);
                                    prockaSearch = String.Concat(procka + "*");
                                    string[] xmlList = Directory.GetFiles(xmlPath, prockaSearch);

                                    //pobiera pelna nazwe folderu SBD_xxxxx
                                    SBD_Color = FolderColor(curColor);

                                    D2.CreateSubdirectory(SBD_Color);

                                    string newSBDfolderFullPath = Path.Combine(xmlPath, SBD_Color);

                                    DirectoryInfo D3 = Directory.CreateDirectory(newSBDfolderFullPath);
                                    MessageBox.Show("dddddd");
                                    string the10xmlorg = "10_XMLs_org";
                                    D3.CreateSubdirectory(the10xmlorg);

                                    foreach (string f in xmlList)
                                    {
                                        string fName = f.Substring(xmlPath.Length + 1);

                                        // Use the Path.Combine method to safely append the file name to the path.
                                        // Will overwrite if the destination file already exists.
                                        File.Copy(Path.Combine(xmlPath, fName), Path.Combine(Path.Combine(parent, SBD_Color), fName), true);
                                        copyCounter += 1;
                                    }
                                }
                            }
                        }
                    }
                    if (copyCounter == xmls.Length)
                    {
                        MessageBox.Show("Copied: " + copyCounter.ToString() + " / " + xmls.Length.ToString() + "\n" + "\n" + "OK!");
                    }
                    else
                    {
                        MessageBox.Show("ERROR! Copied " + copyCounter.ToString() + " / " + xmls.Length.ToString() + "\n" + "\n" + "Did you choose right batch number?");
                    }
                    excel.xClose();
                } // else in
            }     // else
        }