Пример #1
0
        private void BgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (!errorClamp.Clamptype.Contains("PC"))
                {
                    if (!Directory.Exists(save + @"\Final Control"))
                    {
                        Directory.CreateDirectory(save + @"\Final Control");
                    }
                    string dest     = save + @"\Final Control";
                    string destfile = "FC " + DateTime.Now.ToString("dd-MM-yyyy") + " " + textBox3.Text + " " + textBox4.Text + ".xlsx";

                    File.Copy(Path.Combine(direktorijum, "final control.xlsx"), Path.Combine(dest, destfile), true);

                    string editfile = dest + "\\" + destfile;

                    resultDB = ClampOperations.InsertClamp(errorClamp);
                    //ExcellClass.crateFinalControl(@"C:\Users\AleksandraTos\Documents\Visual Studio 2008\Projects\Control Generator\bin\Debug\final control.xlsx", @"Desktop\final control.xlsx", errorClamp);
                    resultEX = ExcellClass.crateFinalControl(editfile, errorClamp);
                }
                else
                {
                    if (!Directory.Exists(save + @"\Final Control"))
                    {
                        Directory.CreateDirectory(save + @"\Final Control");
                    }
                    string dest     = save + @"\Final Control";
                    string destfile = "FC " + DateTime.Now.ToString("dd-MM-yyyy") + " " + textBox3.Text + " " + textBox4.Text + ".xlsx";

                    File.Copy(Path.Combine(direktorijum, "final control PC.xlsx"), Path.Combine(dest, destfile), true);

                    string editfile = dest + "\\" + destfile;

                    resultDB = ClampOperations.InsertClamp(errorClamp);
                    //ExcellClass.crateFinalControl(@"C:\Users\AleksandraTos\Documents\Visual Studio 2008\Projects\Control Generator\bin\Debug\final control.xlsx", @"Desktop\final control.xlsx", errorClamp);
                    resultEX = ExcellClass.crateFinalControl(editfile, errorClamp);
                }
            }
            catch (Exception ex)
            {
                string newfolder = direktorijum + "\\Logs";
                if (!Directory.Exists(newfolder))
                {
                    Directory.CreateDirectory(newfolder);
                }
                newfolder += "\\log1" + DateTime.Now.ToString("dd_MM_yyyy hh_mm_ss") + ".txt";
                StreamWriter sw = new StreamWriter(newfolder);
                sw.Write(ex.ToString());
                sw.Close();
            }
        }
Пример #2
0
        private void BgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <Clamp> counter = new List <Clamp>();

            if (buttonpressedPL && !buttonpressedFCR)
            {
                counter = ClampOperations.ReturnClampPackingList(textBox3.Text, textBox4.Text);
                if (counter.Count > 0)
                {
                    if (!Directory.Exists(save + @"\Packing List"))
                    {
                        Directory.CreateDirectory(save + @"\Packing List");
                    }
                    string dest     = save + @"\Packing List";
                    string destfile = "PL " + DateTime.Now.ToString("dd-MM-yyyy -- HH-mm-ss") + ".xlsx";

                    File.Copy(Path.Combine(direktorijum, "packing list.xlsx"), Path.Combine(dest, destfile), true);

                    string editfile = dest + "\\" + destfile;

                    resultPL = ExcellClass.createPackingList(editfile, counter, paramPL, ClampOperations.ReturnClampRN(textBox3.Text, textBox4.Text));

                    buttonpressedPL = false;

                    Process process = new Process();
                    process = Process.Start(editfile);
                }
                else
                {
                    resultPL = false;
                }
            }
            if (buttonpressedFCR && !buttonpressedPL)
            {
                counter = ClampOperations.ReturnClampFCR(textBox1.Text, textBox2.Text);
                if (counter.Count > 0)
                {
                    if (!Directory.Exists(save + @"\Final Control Report"))
                    {
                        Directory.CreateDirectory(save + @"\Final Control Report");
                    }
                    string dest     = save + @"\Final Control Report";
                    string destfile = "FCR " + DateTime.Now.ToString("dd-MM-yyyy -- HH-mm-ss") + ".xlsx";

                    File.Copy(Path.Combine(direktorijum, "final control report.xlsx"), Path.Combine(dest, destfile), true);

                    string editfile = dest + "\\" + destfile;

                    resultFCR = ExcellClass.createFinalControlReport(editfile, counter, dateTimePicker1.Value.ToString("dd-MM-yyyy"), ClampOperations.ReturnClampRN(textBox1.Text, textBox2.Text));

                    buttonpressedFCR = false;

                    Process process = new Process();
                    process = Process.Start(editfile);
                }
                else
                {
                    resultFCR = false;
                }
            }
        }