Exemplo n.º 1
0
 private void popuniPolja(Part part, PartSifrarnik partSf)
 {
     CategoryNameTB.Text      = workingPartSifrarnik.CategoryName;
     PartNameTB.Text          = workingPartSifrarnik.PartName;
     SubPartNameTB.Text       = workingPartSifrarnik.SubPartName;
     PartIDTB.Text            = part.PartID.ToString();
     PartSNTB.Text            = part.SN;
     PartCNTB.Text            = part.CN;
     PartName.Text            = partSf.FullName;
     DateIn.Text              = part.DateIn;
     DateOut.Text             = part.DateOut;
     DateSend.Text            = part.DateSend;
     StorageID.Text           = part.StorageID.ToString();
     State.Text               = part.State;
     CompanyOwner.Text        = part.CompanyO;
     CompanyOwnerName.Text    = cmpO.Name;
     CompanyCustomer.Text     = part.CompanyC;
     CompanyCustomerName.Text = cmpC.Name;
     PartCode.Text            = string.Format("{0: 000 000 000}", workingPartSifrarnik.FullCode);
     FullCode.Text            = string.Format("{0: 00 00 000 000 000}", workingPart.CodePartFull);
     PartNumber.Text          = workingPartSifrarnik.PartNumber;
     InKN.Text      = workingPartSifrarnik.PriceInKn.ToString();
     OutKN.Text     = workingPartSifrarnik.PriceOutKn.ToString();
     InEUR.Text     = workingPartSifrarnik.PriceInEur.ToString();
     OutERU.Text    = workingPartSifrarnik.PriceOutEur.ToString();
     Packaging.Text = workingPartSifrarnik.Packing;
 }
Exemplo n.º 2
0
        private void PartNameCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            tempSifPart = null;

            if (CustomerCB.Text.Equals("") || CustomerCB.Text.Equals("Customer"))
            {
                MessageBox.Show("Please, select company first.", "Caution", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                indexPartCB = PartNameCB.SelectedIndex;

                tempSifPart = sifrarnikList.ElementAt(indexPartCB);

                String prtCod = String.Format("{0:000 000 000}", tempSifPart.FullCode);
                PartCodeTB.Text = String.Format("{0:00}", mainCmp.Code) + String.Format("{0:00}" + " ", customerCmp.Code) + prtCod;

                if (radioButtonHRV.Checked)
                {
                    PriceTB.Text = CheckIfKNZero(tempSifPart);
                }
                else
                {
                    PriceTB.Text = CheckIfKNZero(tempSifPart);
                }

                PriceINEURTB.Text  = String.Format("{0:N2}", tempSifPart.PriceInEur);
                PriceINKNTB.Text   = String.Format("{0:N2}", tempSifPart.PriceInKn);
                PriceOUTEURTB.Text = String.Format("{0:N2}", tempSifPart.PriceOutEur);
                PriceOUTKNTB.Text  = String.Format("{0:N2}", tempSifPart.PriceOutKn);
            }
        }
Exemplo n.º 3
0
 private void CNsearch_SelectedIndexChanged_1(object sender, EventArgs e)
 {
     selectedIndex        = CNsearch.SelectedIndex;
     workingPart          = partList[selectedIndex];
     workingPartSifrarnik = partListSifrarnik.Find(x => x.FullCode == workingPart.PartialCode);
     cmpO = cmp.Find(x => x.Code == workingPart.CompanyO);
     cmpC = cmp.Find(x => x.Code == workingPart.CompanyC);
     popuniPolja(workingPart, workingPartSifrarnik);
 }
Exemplo n.º 4
0
        private void sSubPartName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Program.LoadStart();

                sSubPartNameCode.ResetText();

                sSubPartNameCodeNew.Enabled = true;
                sSubPartNameNew.Enabled     = true;

                foreach (KeyValuePair <long, String> item in subpartSifrarnik)
                {
                    if (item.Value.Equals(sSubPartName.SelectedItem.ToString()))
                    {
                        sSubPartNameCode.Text = item.Key.ToString();
                        prtSif = partListSifrarnik.Find(x => x.CategoryCode == long.Parse(sCategoryCode.Text) && x.PartCode == long.Parse(sPartNameCode.Text) && x.SubPartCode == item.Key);

                        sSubPartNameCodeNew.Items.Clear();
                        sSubPartNameCodeNew.ResetText();
                        sSubPartNameCodeNew.Items.Add(String.Format("{0:000}", item.Key));
                        sSubPartNameCodeNew.SelectedIndex = 0;
                        sSubPartNameCodeNew.Enabled       = false;

                        sSubPartNameNew.Items.Clear();
                        sSubPartNameNew.ResetText();
                        sSubPartNameNew.Items.Add(item.Value);
                        sSubPartNameNew.SelectedIndex = 0;
                        sSubPartNameNew.Enabled       = false;

                        PriceINKNTB.Text   = prtSif.PriceInKn.ToString();
                        PriceOUTKNTB.Text  = prtSif.PriceOutKn.ToString();
                        PriceINEURTB.Text  = prtSif.PriceInEur.ToString();
                        PriceOUTEURTB.Text = prtSif.PriceOutEur.ToString();
                        PackingCB.Text     = prtSif.Packing;
                        PartNumberTB.Text  = prtSif.PartNumber;

                        break;
                    }
                }
            }
            catch (Exception e1)
            {
                Program.LoadStop();
                //MessageBox.Show(e1.Message);
            }
            finally
            {
                PostaviFullCode();
                Program.LoadStop();
            }
        }
Exemplo n.º 5
0
        private String CheckIfKNZero(PartSifrarnik sprt)
        {
            decimal kn  = sprt.PriceOutKn;
            decimal eur = sprt.PriceOutEur;

            if (radioButtonENG.Checked)
            {
                return(String.Format("{0:N2}", eur <= 0 ? kn / (decimal)ech : eur));
            }
            else
            {
                return(String.Format("{0:N2}", kn <= 0 ? eur * (decimal)ech : kn));
            }
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            sPartName.Items.Clear();
            sSubPartName.Items.Clear();


            sCategoryCode.ResetText();
            sCategory.ResetText();
            sPartNameCode.ResetText();
            sPartName.ResetText();
            sSubPartNameCode.ResetText();
            sSubPartName.ResetText();

            sCategoryCodeNew.ResetText();
            sCategoryNew.ResetText();
            sPartNameCodeNew.ResetText();
            sPartNameNew.ResetText();
            sSubPartNameCodeNew.ResetText();
            sSubPartNameNew.ResetText();

            PriceINKNTB.ResetText();
            PriceOUTKNTB.ResetText();
            PriceINEURTB.ResetText();
            PriceOUTEURTB.ResetText();
            PackingCB.ResetText();
            PartNumberTB.ResetText();

            sCategoryCodeNew.Enabled    = true;
            sCategoryNew.Enabled        = true;
            sPartNameCodeNew.Enabled    = true;
            sPartNameNew.Enabled        = true;
            sSubPartNameCodeNew.Enabled = true;
            sSubPartNameNew.Enabled     = true;

            prtSif = null;
            PostaviFullCode();
        }
Exemplo n.º 7
0
        private void button2_Click(object sender, EventArgs e)
        {
            ///////////////// LogMe ////////////////////////
            String    function = this.GetType().FullName + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name;
            String    usedQC   = "Save to db";
            String    data     = "";
            String    Result   = "";
            LogWriter lw       = new LogWriter();
            ////////////////////////////////////////////////
            ///

            Dictionary <String, int> groupArr = new Dictionary <string, int>();

            int ind;

            ind = comboBox5.FindStringExact(comboBox5.Text);

            if (ind < 0)
            {
                comboBox5.ResetText();
            }

            OTPNumber = "";

            if (this.label2.Text.Equals("Name"))
            {
                Result = "Please select company, nothing done.";
                lw.LogMe(function, usedQC, data, Result);
                MessageBox.Show(Result);
                textBox1.SelectAll();
                textBox1.Focus();
            }
            else if (this.listView1.Items.Count == 0)
            {
                Result = "There is no items in list, nothing done.";
                lw.LogMe(function, usedQC, data, Result);
                MessageBox.Show(Result);
                textBox1.SelectAll();
                textBox1.Focus();
            }
            else
            {
                MainCmp mpc = new MainCmp();
                mpc.GetMainCmpByName(Properties.Settings.Default.CmpName);
                cmpS.Clear();
                cmpS = mpc.MainCmpToCompany();

                if (cmpR.GetCompanyByName(label2.Text.Trim()))
                {
                    try
                    {
                        List <String>    arr = new List <string>();
                        ConnectionHelper cn  = new ConnectionHelper();
                        using (SqlConnection cnnPR = cn.Connect(WorkingUser.Username, WorkingUser.Password))
                        {
                            QueryCommands qc = new QueryCommands();

                            if (cn.TestConnection(cnnPR))
                            {
                                //Provjera da li brojcano odgovaraju dijelovi

                                String testStr;

                                groupArr.Add(listView1.Items[0].SubItems[2].Text + "_" + listView1.Items[0].SubItems[3].Text + "_" +
                                             listView1.Items[0].SubItems[4].Text + "_" + listView1.Items[0].SubItems[5].Text + "_" + WorkingUser.RegionID.ToString(), 1);

                                for (int i = 1; i < listView1.Items.Count; i++)
                                {
                                    testStr = listView1.Items[i].SubItems[2].Text + "_" + listView1.Items[i].SubItems[3].Text + "_" +
                                              listView1.Items[i].SubItems[4].Text + "_" + listView1.Items[i].SubItems[5].Text + "_" + WorkingUser.RegionID.ToString();

                                    if (groupArr.ContainsKey(testStr))
                                    {
                                        groupArr[testStr] = groupArr[testStr] + 1;
                                    }
                                    else
                                    {
                                        groupArr.Add(testStr, 1);
                                    }
                                }

                                for (int i = 0; i < groupArr.Count(); i++)
                                {
                                    var testArr = groupArr.ElementAt(i).Key.Split('_');

                                    int prtConut = qc.GetPartCountByCodeSNCNStateStorage(WorkingUser.Username, WorkingUser.Password,
                                                                                         long.Parse(testArr[0]),
                                                                                         testArr[1],
                                                                                         testArr[2],
                                                                                         testArr[3],
                                                                                         long.Parse(testArr[4]));

                                    if (groupArr[groupArr.ElementAt(i).Key] > prtConut)
                                    {
                                        data   = testArr[0] + ", " + testArr[1] + ", " + testArr[2] + ", " + testArr[3] + ", " + prtConut + ", " + groupArr[groupArr.ElementAt(i).Key];
                                        Result = "You do not have enough patrs in you storage:" +
                                                 "\n\n Code: " + testArr[0] +
                                                 "\n SN:  " + testArr[1] +
                                                 "\n CN:  " + testArr[2] +
                                                 "\n State: " + testArr[3] +
                                                 "\n\nYou have: " + prtConut +
                                                 "\nYou want: " + groupArr[groupArr.ElementAt(i).Key] +
                                                 "\n\nNothing Done.";
                                        lw.LogMe(function, usedQC, data, Result);
                                        MessageBox.Show(Result, "Caution", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                        return;
                                    }
                                }

                                //Provjera da li se dijelovi nalaze u mom skladistu
                                for (int i = 0; i < listView1.Items.Count; i++)
                                {
                                    if (qc.GetPartIDCompareCodeSNCNStorage(WorkingUser.Username, WorkingUser.Password,
                                                                           long.Parse(listView1.Items[i].SubItems[2].Text),
                                                                           listView1.Items[i].SubItems[3].Text,
                                                                           listView1.Items[i].SubItems[4].Text,
                                                                           WorkingUser.RegionID)[0].Equals("nok"))
                                    {
                                        data   = listView1.Items[i].SubItems[2].Text + ", " + listView1.Items[i].Index + 1;
                                        Result = "There is no part in your storage with: \n\n Code: " + listView1.Items[i].SubItems[2].Text + "\n on position " + (listView1.Items[i].Index + 1) + ". \n\nNothing Done.";
                                        lw.LogMe(function, usedQC, data, Result);
                                        MessageBox.Show(Result);

                                        textBox1.SelectAll();
                                        textBox1.Focus();
                                        return;
                                    }
                                }

                                //Provjera i spremanje u bazu
                                List <String> allRegions = new List <string>();
                                allRegions = qc.GetAllRegions();

                                int index = resultArrC.FindIndex(resultArrC => resultArrC.Name.Equals(label2.Text));

                                if (resultArrC[index].RegionID != WorkingUser.RegionID)
                                {
                                    for (int i = 0; i < listView1.Items.Count; i++) // vec imam provjeru gore kod unosa ali neka ostane(tamo je po imenu)
                                    {
                                        //long test = long.Parse(listView1.Items[i].SubItems[2].Text.Substring(4)); //DecoderBB
                                        long test = Decoder.GetFullPartCodeLng(listView1.Items[i].SubItems[2].Text);
                                        if (!resultArrSearchCode.Contains(test.ToString()))
                                        {
                                            data   = test.ToString() + ", " + listView1.Items[i].Index + 1;
                                            Result = "There is no part in 'Sifrarnik' with code, = " + test.ToString() + "\n" + "on position " + (listView1.Items[i].Index + 1) + "  \n\nNothing Done.";
                                            lw.LogMe(function, usedQC, data, Result);
                                            MessageBox.Show(Result);

                                            textBox1.SelectAll();
                                            textBox1.Focus();
                                            return;
                                        }
                                    }

                                    //Provjera da li se dijelovi nalaze u mom skladistu i dohvacanje dijelova
                                    List <Part> partList    = new List <Part>();
                                    String      napomenaOTP = napomenaOTPPrint = textBox4.Text;

                                    for (int i = 0; i < groupArr.Count(); i++)
                                    {
                                        PartSifrarnik tempSifPart = new PartSifrarnik();
                                        List <Part>   tempParts   = new List <Part>();
                                        Part          tempPart    = new Part();

                                        tempSifPart.GetPart(Decoder.GetFullPartCodeStr(listView1.Items[i].SubItems[2].Text));

                                        tempParts = tempPart.GetListOfParts(long.Parse(groupArr.ElementAt(i).Key.Split('_')[0]), groupArr.ElementAt(i).Key.Split('_')[1],
                                                                            groupArr.ElementAt(i).Key.Split('_')[2], groupArr.ElementAt(i).Key.Split('_')[3], long.Parse(groupArr.ElementAt(i).Key.Split('_')[4]));

                                        if (tempParts.Count() < groupArr[groupArr.ElementAt(i).Key])
                                        {
                                            data   = groupArr.ElementAt(i).Key.Split('_')[0] + ", " + groupArr.ElementAt(i).Key.Split('_')[1] + ", " + groupArr.ElementAt(i).Key.Split('_')[2] + ", " + groupArr.ElementAt(i).Key.Split('_')[3] + ", " + tempParts.Count + ", " + groupArr[groupArr.ElementAt(i).Key];
                                            Result = "There is no part in your storage with:" + "" +
                                                     "\n\n Code: " + groupArr.ElementAt(i).Key.Split('_')[0] +
                                                     "\n SN:  " + groupArr.ElementAt(i).Key.Split('_')[1] +
                                                     "\n CN:  " + groupArr.ElementAt(i).Key.Split('_')[2] +
                                                     "\n State: " + groupArr.ElementAt(i).Key.Split('_')[3] +
                                                     "\n\nYou have: " + tempParts.Count +
                                                     "\nYou want: " + groupArr[groupArr.ElementAt(i).Key] +
                                                     "\n\nNothing Done.";
                                            lw.LogMe(function, usedQC, data, Result);
                                            MessageBox.Show(Result, "Caution", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                                            textBox1.SelectAll();
                                            textBox1.Focus();
                                            return;
                                        }
                                        else
                                        {
                                            int kk = 0;
                                            foreach (Part prt in tempParts)
                                            {
                                                partList.Add(prt);
                                                kk++;
                                                if (kk == groupArr[groupArr.ElementAt(i).Key])
                                                {
                                                    break;
                                                }
                                            }
                                        }
                                    }

                                    //SPREMANJE U BAZU
                                    if (resultArrC[index].RegionID != Properties.Settings.Default.OstaliIDRegion &&
                                        resultArrC[index].RegionID != Properties.Settings.Default.TransportIDRegion &&
                                        resultArrC[index].RegionID != Properties.Settings.Default.ServisIDRegion)
                                    {
                                        OTPNumber = qc.OTPUnesiUredajeDaSuPrimljeniInner(WorkingUser.Username, WorkingUser.Password, partList, cmpR, cmpS, textBox4.Text, 0);
                                    }
                                    else if (resultArrC[index].RegionID != Properties.Settings.Default.TransportIDRegion &&
                                             resultArrC[index].RegionID != Properties.Settings.Default.ServisIDRegion)
                                    {
                                        OTPNumber = qc.OTPUnesiUredajeDaSuPrimljeni(WorkingUser.Username, WorkingUser.Password, partList, cmpR, cmpS, textBox4.Text, br.FilID);
                                    }
                                    else
                                    {
                                        Result = "Hm... You cant send part to service!";
                                        lw.LogMe(function, usedQC, data, Result);
                                        MessageBox.Show(Result);

                                        textBox1.SelectAll();
                                        textBox1.Focus();
                                        return;
                                    }

                                    if (!OTPNumber.Equals("nok"))
                                    {
                                        PovijestLog pl    = new PovijestLog();
                                        Boolean     saved = false;
                                        for (int k = 0; k < partList.Count; k++)
                                        {
                                            List <Part> tempPart = new List <Part>();
                                            tempPart.Clear();
                                            tempPart.Add(new Part());
                                            tempPart.Add(partList[k]);
                                            if (pl.SaveToPovijestLog(tempPart, DateTime.Now.ToString("dd.MM.yy."), napomenaOTP, cmpR.Name, "", "", "OTP " + Properties.Settings.Default.ShareDocumentName, tempPart[1].State))
                                            {
                                                saved = true;
                                            }
                                            else
                                            {
                                                saved = false;
                                                Properties.Settings.Default.ShareDocumentName = "";
                                                break;
                                            }
                                        }

                                        if (Program.SaveDocumentsPDF)
                                        {
                                            saveToPDF(partList);
                                        }

                                        if (saved)
                                        {
                                            Result = "DONE, document nbr. OTP '" + OTPNumber + "'.";
                                            lw.LogMe(function, usedQC, data, Result);
                                            MessageBox.Show(Result);

                                            partListPrint.Clear();
                                            partListPrint.AddRange(partList);

                                            isOtpremnicaSaved = true;
                                            listView1.Clear();
                                            listView1.View = View.Details;

                                            listView1.Columns.Add("RB");
                                            listView1.Columns.Add("Name");
                                            listView1.Columns.Add("Code");
                                            listView1.Columns.Add("SN");
                                            listView1.Columns.Add("CN");
                                            listView1.Columns.Add("Condition");
                                            textBox4.Clear();
                                            napomenaOTPPrint = napomenaOTP;
                                        }
                                        else
                                        {
                                            Result = "DONE, document nbr. 'OTP " + OTPNumber + "', but not saved in PL.";
                                            lw.LogMe(function, usedQC, data, Result);
                                            MessageBox.Show(Result);

                                            partListPrint.Clear();
                                            partListPrint.AddRange(partList);

                                            isOtpremnicaSaved = true;
                                            listView1.Clear();
                                            listView1.View = View.Details;

                                            listView1.Columns.Add("RB");
                                            listView1.Columns.Add("Name");
                                            listView1.Columns.Add("Code");
                                            listView1.Columns.Add("SN");
                                            listView1.Columns.Add("CN");
                                            listView1.Columns.Add("Condition");
                                            textBox4.Clear();
                                            napomenaOTPPrint = napomenaOTP;
                                        }
                                    }
                                }
                                else
                                {
                                    Result = "Hm... Same receiving and sending company?!";
                                    lw.LogMe(function, usedQC, data, Result);
                                    MessageBox.Show(Result);

                                    textBox1.SelectAll();
                                    textBox1.Focus();
                                    return;
                                }
                            }
                            cnnPR.Close();
                        }
                    }
                    catch (Exception e1)
                    {
                        new LogWriter(e1);
                        MessageBox.Show(e1.Message);
                        textBox1.SelectAll();
                        textBox1.Focus();
                    }
                }
                this.printPrewBT.Enabled = isOtpremnicaSaved;
            }
        }
Exemplo n.º 8
0
        void printParts(PrintPageEventArgs e)
        {
            if (!cmpR.GetCompanyInfoByID(off.CustomerID))
            {
                MessageBox.Show("I cant find company.");
                return;
            }

            String oznakaValute = "";

            if (hrv)
            {
                Properties.Settings.Default.LanguageStt = "hrv";
                Thread.CurrentThread.CurrentUICulture   = CultureInfo.GetCultureInfo("hr-HR");
                oznakaValute = "kn";
                eurDjelitelj = 1;
            }
            else
            {
                Properties.Settings.Default.LanguageStt = "eng";
                Thread.CurrentThread.CurrentUICulture   = CultureInfo.GetCultureInfo("en-US");
                oznakaValute = "€";
                eurDjelitelj = off.Eur;
            }

            partRows = Properties.Settings.Default.partRows;
            pageNbr  = Properties.Settings.Default.pageNbr;

            if (datumIzrade.Equals(""))
            {
                datumIzrade = DateTime.Now.ToString("dd.MM.yy.");
            }
            if (datumIspisa.Equals(""))
            {
                datumIspisa = DateTime.Now.ToString("dd.MM.yy.");
            }
            if (izradioUser.Equals(""))
            {
                izradioUser = WorkingUser.UserID.ToString();
            }
            if (izradioRegija.Equals(""))
            {
                izradioRegija = WorkingUser.RegionID.ToString();
            }

            e.HasMorePages = false;

            PageSettings page = GetPrinterPageInfo();

            RectangleF area    = page.PrintableArea;
            Rectangle  bounds  = page.Bounds;
            Margins    margins = page.Margins;

            //Podesavanje pocetka ispisa za prvi list od vrha (default = 100)
            margins.Bottom = margins.Bottom / 2;
            margins.Top    = margins.Top / 2;

            headerpointVer = margins.Top;
            headerpointHor = bounds.Right - margins.Right;

            try
            {
                String workingStr   = "";
                float  measureStr   = 0;
                float  measureField = 0;

                using (img)
                {
                    int dodatak   = 15;
                    int rowHeight = 20;
                    int total     = bounds.Right - margins.Right - margins.Left;

                    int kraj    = bounds.Right - margins.Right;
                    int polje   = total / 30;
                    int pocetak = margins.Left - (polje * 1);
                    int rb      = pocetak + (polje * 1);
                    int name    = margins.Left + (polje * 10);     //8
                    int code    = margins.Left + (polje * 14);     //4

                    int price       = margins.Left + (polje * 17); //3
                    int workTime    = margins.Left + (polje * 19); //3
                    int rebate      = margins.Left + (polje * 21); //3
                    int amount      = margins.Left + (polje * 23); //2
                    int rebatePrice = margins.Left + (polje * 27); //3

                    int     indexStavke = invPrtList.Count == 0 ? 0 : invPrtList.Count - 1;
                    Boolean konverzija  = invPrtList[indexStavke].Konverzija.ToString().Equals("0") ? false : true;

                    if (pageNbr == 1)
                    {
                        //Sender/Receiver Company Info
                        int razmakZaCustomera = 0;

                        e.Graphics.DrawString(Properties.strings.customer + ": ", new Font("Calibri light", fontSizeS - 1, FontStyle.Underline | FontStyle.Italic), Brushes.Black, new Point(margins.Left, margins.Top + (moveBy / 2)));
                        e.Graphics.DrawString(cmpR.Name, new Font("Calibri light", fontSizeS, FontStyle.Bold), Brushes.Black, new Point(margins.Left, razmakZaCustomera + margins.Top + (moveBy * 2)));
                        razmakZaCustomera += 6;
                        e.Graphics.DrawString(cmpR.Address, new Font("Calibri light", fontSizeS, FontStyle.Regular), Brushes.Black, new Point(margins.Left, razmakZaCustomera + margins.Top + (moveBy * 3)));
                        razmakZaCustomera += 2;
                        e.Graphics.DrawString(cmpR.Country + " - " + cmpR.City + ", " + cmpR.PB, new Font("Calibri light", fontSizeS, FontStyle.Regular), Brushes.Black, new Point(margins.Left, razmakZaCustomera + margins.Top + (moveBy * 4)));
                        razmakZaCustomera += 4;
                        e.Graphics.DrawString(Properties.strings.VAT + ": " + cmpR.OIB, new Font("Calibri light", fontSizeS, FontStyle.Regular), Brushes.Black, new Point(margins.Left, razmakZaCustomera + margins.Top + (moveBy * 5)));
                        razmakZaCustomera += 2;
                        e.Graphics.DrawString(Properties.strings.SWIFT + ": " + cmpR.BIC, new Font("Calibri light", fontSizeS, FontStyle.Regular), Brushes.Black, new Point(margins.Left, razmakZaCustomera + margins.Top + (moveBy * 6)));
                        razmakZaCustomera += 4;
                        e.Graphics.DrawString(Properties.strings.WorkHour + ": " + String.Format("{0:N2}", cmpR.KN / eurDjelitelj) + " " + oznakaValute, new Font("Calibri light", fontSizeS, FontStyle.Regular), Brushes.Black, new Point(margins.Left, razmakZaCustomera + margins.Top + (moveBy * 7)));
                        razmakZaCustomera += 2;
                        e.Graphics.DrawString(Properties.strings.MinWorkTime + ": " + Properties.Settings.Default.ObracunskaJedinica.ToString() + " min", new Font("Calibri light", fontSizeS, FontStyle.Regular), Brushes.Black, new Point(margins.Left, razmakZaCustomera + margins.Top + (moveBy * 8)));
                        razmakZaCustomera += 2;
                        e.Graphics.DrawString(Environment.NewLine, new Font("Calibri light", fontSizeS, FontStyle.Regular), Brushes.Black, new Point(margins.Left, razmakZaCustomera + margins.Top + (moveBy * 9 / 2)));

                        headerpointVer = headerpointVer + (moveBy * 9);

                        //NAPOMENA
                        if (!off.Napomena.Equals(""))
                        {
                            if (hrv)
                            {
                                workingStr = "Napomena: ";
                            }
                            else
                            {
                                workingStr = "Note: ";
                            }

                            headerpointVer = headerpointVer + (moveBy * 2);

                            Font ft1 = getFont(8);
                            measureStr = e.Graphics.MeasureString(workingStr, ft1).Width;
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft1.Size, FontStyle.Bold), Brushes.Black, new Point(rb, headerpointVer + moveBy));

                            measureField = workTime - (rb + (int)measureStr + 4);

                            workingStr = off.Napomena;
                            measureStr = e.Graphics.MeasureString(workingStr, ft1).Width;

                            int    ii          = 1;
                            int    secondLine  = 0;
                            int    wsNAPOMENAw = (int)e.Graphics.MeasureString(Properties.strings.NOTE + ":", ft1).Width;
                            String ws1         = "";

                            while (measureStr > measureField)
                            {
                                ws1 = workingStr;
                                int ws1Lenght = (int)e.Graphics.MeasureString(ws1, ft1).Width;
                                while (ws1Lenght > measureField)
                                {
                                    ws1       = ws1.Substring(0, ws1.Length - 1);
                                    ws1Lenght = (int)e.Graphics.MeasureString(ws1, ft1).Width;
                                }

                                if (headerpointVer + moveBy * ii < margins.Top + imgH + (moveBy * 7) + 75)
                                {
                                    e.Graphics.DrawString(ws1, new Font("Calibri light", ft1.Size, FontStyle.Regular), Brushes.Black, new Point(rb + wsNAPOMENAw + 4, headerpointVer + moveBy * ii));
                                    ii++;
                                    secondLine   = wsNAPOMENAw;
                                    workingStr   = workingStr.Substring(ws1.Length);
                                    measureStr   = e.Graphics.MeasureString(workingStr, ft1).Width;
                                    measureField = workTime - rb - (secondLine);
                                }
                            }
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft1.Size, FontStyle.Regular), Brushes.Black, new Point(rb + wsNAPOMENAw + 4, headerpointVer + moveBy * ii));
                        }

                        //MyCompany Info
                        e.Graphics.DrawImage(img, bounds.Right - imgW - margins.Right, bounds.Top + margins.Top, imgW, imgH);

                        String MainCmpPrintAddress = Properties.Settings.Default.CmpAddress + ", " + Properties.Settings.Default.CmpCountry + " - " + Properties.Settings.Default.CmpPB + " " + Properties.Settings.Default.CmpCity;

                        e.Graphics.DrawString(Properties.Settings.Default.CmpName, new Font("Calibri light", fontSizeR, FontStyle.Bold), Brushes.Black, new Point(bounds.Right - margins.Right - (imgW - imgW / 7), margins.Top + imgH + (moveBy)));
                        e.Graphics.DrawString(MainCmpPrintAddress, new Font("Calibri light", fontSizeR, FontStyle.Regular), Brushes.Black, new Point(bounds.Right - margins.Right - (imgW - imgW / 7), margins.Top + imgH + (moveBy * 2)));
                        e.Graphics.DrawString("MB: " + Properties.Settings.Default.CmpMB, new Font("Calibri light", fontSizeR, FontStyle.Regular), Brushes.Black, new Point(bounds.Right - margins.Right - (imgW - imgW / 7), margins.Top + imgH + (moveBy * 3)));
                        if (konverzija)
                        {
                            e.Graphics.DrawString(Properties.strings.VAT + ": " + Properties.Settings.Default.CmpVAT, new Font("Calibri light", fontSizeR, FontStyle.Regular), Brushes.Black, new Point(bounds.Right - margins.Right - (imgW - imgW / 7), margins.Top + imgH + (moveBy * 4)));
                        }
                        else
                        {
                            e.Graphics.DrawString(Properties.strings.VAT + ": HR" + Properties.Settings.Default.CmpVAT, new Font("Calibri light", fontSizeR, FontStyle.Regular), Brushes.Black, new Point(bounds.Right - margins.Right - (imgW - imgW / 7), margins.Top + imgH + (moveBy * 4)));
                        }
                        e.Graphics.DrawString("Tel: " + Properties.Settings.Default.CmpPhone, new Font("Calibri light", fontSizeR, FontStyle.Regular), Brushes.Black, new Point(bounds.Right - margins.Right - (imgW - imgW / 7), margins.Top + imgH + (moveBy * 5)));
                        e.Graphics.DrawString("IBAN: " + Properties.Settings.Default.CmpIBAN, new Font("Calibri light", fontSizeR, FontStyle.Regular), Brushes.Black, new Point(bounds.Right - margins.Right - (imgW - imgW / 7), margins.Top + imgH + (moveBy * 6)));
                        e.Graphics.DrawString(Properties.strings.SWIFT + ": " + Properties.Settings.Default.CmpSWIFT, new Font("Calibri light", fontSizeR, FontStyle.Regular), Brushes.Black, new Point(bounds.Right - margins.Right - (imgW - imgW / 7), margins.Top + imgH + (moveBy * 7)));

                        headerpointVer = margins.Top + imgH + (moveBy * 7) + 100;
                        headerpointHor = bounds.Right - margins.Right - imgW;

                        String umjestoPlatite;

                        if (hrv)
                        {
                            workingStr     = "Pounda br.";
                            umjestoPlatite = "Ponuda vrijedi";
                        }
                        else
                        {
                            workingStr     = "Offer nbr.";
                            umjestoPlatite = "Offer is valid";
                        }

                        e.Graphics.DrawString(workingStr + "  " + brojPonude, new Font("Calibri light", fontSizeS, FontStyle.Bold), Brushes.Black, new Point(margins.Left, headerpointVer + (moveBy * 2)));

                        workingStr = umjestoPlatite;
                        measureStr = e.Graphics.MeasureString(workingStr, getFont(10)).Width;
                        e.Graphics.DrawString(workingStr, new Font("Calibri light", fontSizeS, FontStyle.Bold), Brushes.Black, new Point(bounds.Right - margins.Left - (int)measureStr, headerpointVer + moveBy - 4));

                        workingStr = off.Valuta.ToString() + " " + Properties.strings.Days;
                        measureStr = e.Graphics.MeasureString(workingStr, getFont(10)).Width;
                        e.Graphics.DrawString(workingStr, new Font("Calibri light", fontSizeS, FontStyle.Bold), Brushes.Black, new Point(bounds.Right - margins.Left - (int)measureStr, headerpointVer + (moveBy * 2)));

                        headerpointVer = headerpointVer + (moveBy * 6);
                    }
                    else
                    {
                        imgW = imgW / 2;                       //80
                        imgH = (int)((double)imgW / imgScale); //75 //40
                        e.Graphics.DrawImage(img, bounds.Right - imgW - margins.Right, bounds.Top + margins.Top, imgW, imgH);
                        headerpointVer = bounds.Top + margins.Top + imgH + 50;
                    }

                    Font fnt = getFont(fontSizeR);

                    if (partRows < invPrtList.Count)
                    {
                        //e.Graphics.FillRectangle(new SolidBrush(Color.DeepSkyBlue), rb, headerpointVer, total, rowHeight + dodatak);
                        e.Graphics.FillRectangle(exeBrush, rb, headerpointVer, total, rowHeight + dodatak);
                        e.Graphics.DrawRectangle(new Pen(Brushes.Black), rb, headerpointVer, total, rowHeight + dodatak);

                        float[] dashValues = { 1, 1, 1, 1 };
                        Pen     blackPen   = new Pen(Color.Black, 1);
                        //blackPen.DashPattern = dashValues;
                        blackPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;

                        //GRID
                        e.Graphics.DrawLine(blackPen, new Point(name, headerpointVer), new Point(name, headerpointVer + rowHeight + dodatak));
                        e.Graphics.DrawLine(blackPen, new Point(code, headerpointVer), new Point(code, headerpointVer + rowHeight + dodatak));
                        e.Graphics.DrawLine(blackPen, new Point(price, headerpointVer), new Point(price, headerpointVer + rowHeight + dodatak));

                        e.Graphics.DrawLine(blackPen, new Point(workTime, headerpointVer), new Point(workTime, headerpointVer + rowHeight + dodatak));
                        e.Graphics.DrawLine(blackPen, new Point(rebate, headerpointVer), new Point(rebate, headerpointVer + rowHeight + dodatak));
                        e.Graphics.DrawLine(blackPen, new Point(amount, headerpointVer), new Point(amount, headerpointVer + rowHeight + dodatak));
                        e.Graphics.DrawLine(blackPen, new Point(rebatePrice, headerpointVer), new Point(rebatePrice, headerpointVer + rowHeight + dodatak)); //new Pen(Brushes.Black)

                        workingStr   = "RB";
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, polje);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = polje;
                        e.Graphics.DrawString(workingStr, getFont(6), Brushes.Black, new Point(pocetak + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight));

                        Brush tmpBrush = Brushes.White;

                        workingStr   = Properties.strings.NAME;
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, name - rb);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = name - rb;
                        e.Graphics.DrawString(workingStr, fnt, tmpBrush, new Point(rb + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight / 2));

                        workingStr   = Properties.strings.CODE;
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, code - name);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = code - name;
                        e.Graphics.DrawString(workingStr, fnt, tmpBrush, new Point(name + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight / 2));

                        workingStr   = Properties.strings.PRICE;
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, price - code);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = price - code;
                        e.Graphics.DrawString(workingStr, fnt, tmpBrush, new Point(code + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight / 2));

                        /////////////////////
                        workingStr   = Properties.strings.WORKTIME1;
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, workTime - price);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = workTime - price;
                        e.Graphics.DrawString(workingStr, fnt, tmpBrush, new Point(price + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight / 4));

                        workingStr   = Properties.strings.WORKTIME2;
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, workTime - price);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = workTime - price;
                        e.Graphics.DrawString(workingStr, fnt, tmpBrush, new Point(price + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight));
                        /////////////////////

                        workingStr   = Properties.strings.REBATE;
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, rebate - workTime);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = rebate - workTime;
                        e.Graphics.DrawString(workingStr, fnt, tmpBrush, new Point(workTime + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight / 2));

                        workingStr   = Properties.strings.QUA + ".";
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, amount - rebate);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = amount - rebate;
                        e.Graphics.DrawString(workingStr, fnt, tmpBrush, new Point(rebate + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight / 2));

                        /////////////////////
                        workingStr   = Properties.strings.REBATEPRICE1;
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, rebatePrice - amount);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = rebatePrice - amount;
                        e.Graphics.DrawString(workingStr, fnt, tmpBrush, new Point(amount + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight / 4));

                        workingStr   = Properties.strings.REBATEPRICE2;
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, rebatePrice - amount);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = rebatePrice - amount;
                        e.Graphics.DrawString(workingStr, fnt, tmpBrush, new Point(amount + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight));
                        /////////////////////

                        workingStr   = Properties.strings.TOTAL;
                        fnt          = fitFontSizeBold(e, workingStr, fontSizeR, kraj - rebatePrice);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = kraj - rebatePrice;
                        e.Graphics.DrawString(workingStr, fnt, tmpBrush, new Point(rebatePrice + (((int)measureField - (int)measureStr) / 2), headerpointVer + rowHeight / 2));
                    }

                    headerpointVer += (moveBy * 2);// moveBy;

                    for (; partRows < invPrtList.Count; partRows++)
                    {
                        if (headerpointVer + (moveBy * 4) + 20 > bounds.Bottom - margins.Bottom - 20)
                        {
                            e.HasMorePages = true;
                            break;
                        }

                        String        partCode = String.Format("{0:00}", long.Parse(Properties.Settings.Default.CmpCode)) + String.Format("{0:00}", cmpR.Code) + Decoder.GetFullPartCodeStr(invPrtList[partRows].PartCode);
                        PartSifrarnik tmpPart  = qc.PartInfoByFullCodeSifrarnik(invPrtList[partRows].PartCode);

                        headerpointVer = headerpointVer + moveBy; // (moveBy * 2);

                        workingStr   = (partRows + 1).ToString(); //tu
                        measureField = polje;
                        fnt          = fitFontSize(e, workingStr, fontSizeR, measureField);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        e.Graphics.DrawString(workingStr, fnt, Brushes.Black, new Point(pocetak + (((int)measureField - (int)measureStr) / 2), headerpointVer + moveBy));


                        ///////////////////////////////////////////////////////

                        workingStr = tmpPart.FullName;//tu partRows

                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        measureField = name - rb;

                        List <String> naziv = wordWrraper(e, measureField, workingStr, fontSizeR);

                        int pamtiHeadPointVer = headerpointVer;

                        foreach (String n in naziv)
                        {
                            fnt = fitFontSize(e, n, fontSizeR, measureField);
                            e.Graphics.DrawString(n, fnt, Brushes.Black, new Point(rb, headerpointVer + moveBy));
                            headerpointVer += moveBy;
                        }

                        ///////////////////////////////////////////////////////

                        //workingStr = tmpPart.FullName;//tu partRows
                        //measureStr = e.Graphics.MeasureString(workingStr, fnt).Width;
                        //measureField = name - rb;
                        //fnt = fitFontSize(e, workingStr, fontSizeR, measureField);
                        //e.Graphics.DrawString(workingStr, fnt, Brushes.Black, new Point(rb, headerpointVer + moveBy));

                        workingStr   = partCode;//tu partRows
                        measureField = code - name;
                        fnt          = fitFontSize(e, workingStr, fontSizeR, measureField);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        e.Graphics.DrawString(workingStr, fnt, Brushes.Black, new Point(name + (((int)measureField - (int)measureStr) / 2), pamtiHeadPointVer + moveBy));

                        if (konverzija)
                        {
                            workingStr = String.Format("{0:N2}", decimal.Parse(invPrtList[partRows].IznosPart) / eurDjelitelj) + " " + oznakaValute;
                        }
                        else
                        {
                            workingStr = String.Format("{0:N2}", decimal.Parse(invPrtList[partRows].IznosPart)) + " " + oznakaValute;
                        }
                        measureField = price - code;
                        fnt          = fitFontSize(e, workingStr, fontSizeR, measureField);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        e.Graphics.DrawString(workingStr, fnt, Brushes.Black, new Point(price - (int)measureStr, pamtiHeadPointVer + moveBy));

                        workingStr   = invPrtList[partRows].VrijemeRada;
                        measureField = workTime - price;
                        fnt          = fitFontSize(e, workingStr, fontSizeR, measureField);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        e.Graphics.DrawString(workingStr, fnt, Brushes.Black, new Point(price + (((int)measureField - (int)measureStr) / 2), pamtiHeadPointVer + moveBy));

                        workingStr   = String.Format("{0:N2}", invPrtList[partRows].Rabat) + " %";
                        measureField = rebate - workTime;
                        fnt          = fitFontSize(e, workingStr, fontSizeR, measureField);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        e.Graphics.DrawString(workingStr, fnt, Brushes.Black, new Point(workTime + ((int)measureField - (int)measureStr), pamtiHeadPointVer + moveBy));

                        workingStr   = invPrtList[partRows].Kolicina.ToString();
                        measureField = amount - rebate;
                        fnt          = fitFontSize(e, workingStr, fontSizeR, measureField);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        e.Graphics.DrawString(workingStr, fnt, Brushes.Black, new Point(rebate + (((int)measureField - (int)measureStr) / 2), pamtiHeadPointVer + moveBy));

                        if (konverzija)
                        {
                            workingStr = String.Format("{0:N2}", decimal.Parse(invPrtList[partRows].IznosRabat) / eurDjelitelj) + " " + oznakaValute;
                        }
                        else
                        {
                            workingStr = String.Format("{0:N2}", decimal.Parse(invPrtList[partRows].IznosRabat)) + " " + oznakaValute;
                        }
                        measureField = rebatePrice - amount;
                        fnt          = fitFontSize(e, workingStr, fontSizeR, measureField);
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        e.Graphics.DrawString(workingStr, fnt, Brushes.Black, new Point(rebatePrice - (int)measureStr, pamtiHeadPointVer + moveBy));

                        if (konverzija)
                        {
                            workingStr = String.Format("{0:N2}", decimal.Parse(invPrtList[partRows].IznosTotal) / eurDjelitelj) + " " + oznakaValute;
                        }
                        else
                        {
                            workingStr = String.Format("{0:N2}", decimal.Parse(invPrtList[partRows].IznosTotal)) + " " + oznakaValute;
                        }
                        measureField = kraj - rebatePrice;
                        fnt          = fitFontSize(e, workingStr, fontSizeR, measureField);; //tu
                        measureStr   = e.Graphics.MeasureString(workingStr, fnt).Width;
                        e.Graphics.DrawString(workingStr, fnt, Brushes.Black, new Point(kraj - (int)measureStr, pamtiHeadPointVer + moveBy));

                        if (partRows >= invPrtList.Count - 1)
                        {
                            //headerpointVer = headerpointVer + (moveBy * 2);
                            headerpointVer = headerpointVer + moveBy;
                            e.Graphics.DrawLine(new Pen(Brushes.Black), rb, headerpointVer + moveBy, kraj, headerpointVer + moveBy);
                        }
                    }

                    Properties.Settings.Default.partRows = partRows;

                    if (invPrtList.Count > partRows)
                    {
                        e.HasMorePages = true;
                    }
                    else
                    {
                        Font ft = getFont(10); //tu

                        if (headerpointVer + 120 > bounds.Bottom - margins.Bottom - 20)
                        {
                            e.HasMorePages = true;
                        }
                        else
                        {
                            headerpointVer = headerpointVer + (moveBy * 2);
                            workingStr     = Properties.strings.TaxBase + ":";
                            measureField   = rebatePrice - workTime;
                            measureStr     = e.Graphics.MeasureString(workingStr, ft).Width;
                            e.Graphics.DrawString(workingStr, ft, Brushes.Black, new Point(amount + ((rebatePrice - amount) / 2) - (int)measureStr, headerpointVer + moveBy));


                            if (konverzija)
                            {
                                workingStr = String.Format("{0:N2}", taxBase / eurDjelitelj) + " " + oznakaValute;
                            }
                            else
                            {
                                workingStr = String.Format("{0:N2}", taxBase) + " " + oznakaValute;
                            }
                            measureField = total - rebatePrice;
                            measureStr   = e.Graphics.MeasureString(workingStr, ft).Width;
                            e.Graphics.DrawString(workingStr, ft, Brushes.Black, new Point(kraj - (int)measureStr, headerpointVer + moveBy));


                            headerpointVer = headerpointVer + (moveBy * 2);
                            workingStr     = Properties.strings.TAX + "(" + (hrv ? Properties.Settings.Default.TAX1.ToString() : Properties.Settings.Default.TAX2.ToString()) + "%):";
                            measureField   = rebatePrice - workTime;
                            measureStr     = e.Graphics.MeasureString(workingStr, ft).Width;
                            e.Graphics.DrawString(workingStr, ft, Brushes.Black, new Point(amount + ((rebatePrice - amount) / 2) - (int)measureStr, headerpointVer + moveBy));

                            if (konverzija)
                            {
                                workingStr = String.Format("{0:N2}", totalTax / eurDjelitelj) + " " + oznakaValute;
                            }
                            else
                            {
                                workingStr = String.Format("{0:N2}", totalTax) + " " + oznakaValute;
                            }
                            measureField = total - rebatePrice;
                            measureStr   = e.Graphics.MeasureString(workingStr, ft).Width;
                            e.Graphics.DrawString(workingStr, ft, Brushes.Black, new Point(kraj - (int)measureStr, headerpointVer + moveBy));


                            headerpointVer = headerpointVer + (moveBy * 2);
                            workingStr     = Properties.strings.TotalSum + ":";
                            measureField   = rebatePrice - workTime;
                            measureStr     = e.Graphics.MeasureString(workingStr, ft).Width;
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Bold), Brushes.Black, new Point(amount + ((rebatePrice - amount) / 2) - (int)measureStr, headerpointVer + moveBy));

                            if (konverzija)
                            {
                                workingStr = String.Format("{0:N2}", off.Iznos / eurDjelitelj) + " " + oznakaValute;
                            }
                            else
                            {
                                workingStr = String.Format("{0:N2}", off.Iznos) + " " + oznakaValute;
                            }
                            measureField = total - rebatePrice;
                            measureStr   = e.Graphics.MeasureString(workingStr, ft).Width;
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Bold), Brushes.Black, new Point(kraj - (int)measureStr, headerpointVer + moveBy));

                            if (!hrv)
                            {
                                headerpointVer = headerpointVer + (moveBy * 2);
                                workingStr     = Properties.strings.TotalSum + ":";
                                measureField   = rebatePrice - workTime;
                                measureStr     = e.Graphics.MeasureString(workingStr, ft).Width;
                                e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Regular), Brushes.Black, new Point(amount + ((rebatePrice - amount) / 2) - (int)measureStr, headerpointVer + moveBy));

                                workingStr   = String.Format("{0:N2}", off.Iznos * eurDjelitelj) + " kn";
                                measureField = total - rebatePrice;
                                measureStr   = e.Graphics.MeasureString(workingStr, ft).Width;
                                e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Regular), Brushes.Black, new Point(kraj - (int)measureStr, headerpointVer + moveBy));
                            }

                            headerpointVer = headerpointVer - (moveBy * 2);
                        }

                        ///////////////////////////////////////////////////////

                        if (headerpointVer + 200 > bounds.Bottom - margins.Bottom - 20 || e.HasMorePages)
                        {
                            e.HasMorePages = true;
                        }
                        else
                        {
                            ft = getFont(8);

                            headerpointVer = headerpointVer + (moveBy * 3);
                            workingStr     = Properties.strings.DateTime + ":";
                            measureStr     = e.Graphics.MeasureString(workingStr, ft).Width;
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Bold), Brushes.Black, new Point(rb, headerpointVer + moveBy));

                            workingStr = off.DatumIzdano + " " + off.VrijemeIzdano;
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Regular), Brushes.Black, new Point(rb + (int)measureStr + 25, headerpointVer + moveBy));


                            headerpointVer = headerpointVer + moveBy + 4;
                            workingStr     = Properties.strings.PaymentForm + ":";
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Bold), Brushes.Black, new Point(rb, headerpointVer + moveBy));

                            workingStr = off.NacinPlacanja;
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Regular), Brushes.Black, new Point(rb + (int)measureStr + 25, headerpointVer + moveBy));


                            headerpointVer = headerpointVer + moveBy + 4;
                            workingStr     = Properties.strings.OfferValid + ":";
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Bold), Brushes.Black, new Point(rb, headerpointVer + moveBy));

                            workingStr = off.Valuta.ToString() + " " + Properties.strings.Days;
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Regular), Brushes.Black, new Point(rb + (int)measureStr + 25, headerpointVer + moveBy));


                            headerpointVer = headerpointVer + moveBy + 4;
                            workingStr     = Properties.strings.ExcRate + ":";
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Bold), Brushes.Black, new Point(rb, headerpointVer + moveBy));

                            workingStr = off.Eur.ToString() + " kn " + Properties.strings.OnDay + " " + off.DanTecaja;
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Regular), Brushes.Black, new Point(rb + (int)measureStr + 25, headerpointVer + moveBy));


                            headerpointVer = headerpointVer + moveBy + 4;
                            workingStr     = Properties.strings.Operater + ":";
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Bold), Brushes.Black, new Point(rb, headerpointVer + moveBy));

                            workingStr = WorkingUser.Name[0].ToString() + WorkingUser.Surename[0].ToString() + WorkingUser.UserID.ToString();
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Regular), Brushes.Black, new Point(rb + (int)measureStr + 25, headerpointVer + moveBy));


                            String workingStrOsoba = Properties.strings.ResPersone;
                            float  measureStrOsoba = e.Graphics.MeasureString(workingStrOsoba, ft).Width;
                            e.Graphics.DrawString(workingStrOsoba, new Font("Calibri light", ft.Size, FontStyle.Bold), Brushes.Black, new Point(rebatePrice - ((int)measureStrOsoba / 2), headerpointVer + moveBy));

                            workingStrOsoba = Properties.Settings.Default.odgovornaOsoba;
                            measureStrOsoba = e.Graphics.MeasureString(workingStrOsoba, ft).Width;
                            e.Graphics.DrawString(workingStrOsoba, new Font("Calibri light", ft.Size, FontStyle.Regular), Brushes.Black, new Point(rebatePrice - ((int)measureStrOsoba / 2), headerpointVer + (moveBy * 2)));

                            /*
                             * headerpointVer = headerpointVer + moveBy + 4;
                             * workingStr = Properties.strings.OfferConn + ":";
                             * e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Bold), Brushes.Black, new Point(rb, headerpointVer + moveBy));
                             *
                             * workingStr = off.RacunID.ToString();
                             * e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size, FontStyle.Regular), Brushes.Black, new Point(rb + (int)measureStr + 25, headerpointVer + moveBy));
                             */

                            headerpointVer = headerpointVer + (moveBy * 4);
                            if (hrv)
                            {
                                workingStr = Properties.Settings.Default.extraLine1HRTB;
                            }
                            else
                            {
                                workingStr = Properties.Settings.Default.extraLine1ENGTB;
                            }
                            measureStr = e.Graphics.MeasureString(workingStr, ft).Width;
                            e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size - 2, FontStyle.Regular), Brushes.Black, new Point(rb, headerpointVer + moveBy));

                            headerpointVer = headerpointVer + moveBy + 4;
                            if (Properties.Settings.Default.TAX1 == 0)
                            {
                                if (hrv)
                                {
                                    workingStr = Properties.Settings.Default.extraLine2HRTB;
                                }
                                else
                                {
                                    workingStr = Properties.Settings.Default.extraLine2ENGTB;
                                }
                                measureStr = e.Graphics.MeasureString(workingStr, ft).Width;
                                e.Graphics.DrawString(workingStr, new Font("Calibri light", ft.Size - 2, FontStyle.Regular), Brushes.Black, new Point(rb, headerpointVer + moveBy));
                            }
                        }
                    }

                    e.Graphics.DrawString(Properties.strings.Page + " : " + pageNbr, getFont(8), Brushes.Black, new Point(margins.Left, bounds.Bottom - margins.Bottom));

                    if (e.HasMorePages)
                    {
                        Properties.Settings.Default.pageNbr = pageNbr = pageNbr + 1;
                    }
                    else
                    {
                        Properties.Settings.Default.pageNbr  = 1;
                        Properties.Settings.Default.partRows = partRows = 0;
                    }


                    if (hrv)
                    {
                        workingStr = Properties.Settings.Default.thx1HRTB;
                    }
                    else
                    {
                        workingStr = Properties.Settings.Default.thx1ENGTB;
                    }

                    Font fntT = new Font("Ink Free", 14, FontStyle.Regular);
                    measureStr   = e.Graphics.MeasureString(workingStr, fntT).Width;
                    measureField = bounds.Right - margins.Right - margins.Left;
                    e.Graphics.DrawString(workingStr, fntT, exeBrush, new Point(margins.Left + (((int)measureField - (int)measureStr) / 2), bounds.Bottom - margins.Bottom - 20));

                    fnt = fitFontSize(e, (partRows + 1).ToString(), fontSizeR, code - pocetak);

                    workingStr = Properties.Settings.Default.CmpWWW;
                    fnt        = fitFontSize(e, workingStr, fontSizeR, code - pocetak);
                    measureStr = e.Graphics.MeasureString(workingStr, fnt).Width;
                    e.Graphics.DrawString(workingStr, getFont(8), Brushes.Black, new Point(bounds.Right - margins.Right - (int)measureStr, bounds.Bottom - margins.Bottom));
                }

                return;
            }
            catch (Exception e1)
            {
                throw e1;
                //new LogWriter(e1);
                //MessageBox.Show(e1.Message);
            }
        }
Exemplo n.º 9
0
        private void sPartName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Program.LoadStart();

                sPartNameCode.ResetText();
                lastIDSubPart.ResetText();

                sPartNameCodeNew.Enabled = true;
                sPartNameNew.Enabled     = true;

                foreach (KeyValuePair <long, String> item in partSifrarnik)
                {
                    if (item.Value.Equals(sPartName.SelectedItem.ToString()))
                    {
                        sPartNameCode.Text = item.Key.ToString();
                        prtSif             = partListSifrarnik.Find(x => x.CategoryCode == long.Parse(sCategoryCode.Text) && x.PartCode == item.Key && x.SubPartCode == 0);
                        //prtSif = partListSifrarnik.Find(x => x.CategoryCode == long.Parse(sCategoryCode.Text) && x.PartCode == item.Key);

                        sPartNameCodeNew.Items.Clear();
                        sPartNameCodeNew.ResetText();
                        sPartNameCodeNew.Items.Add(String.Format("{0:000}", item.Key / 1000));
                        sPartNameCodeNew.SelectedIndex = 0;
                        sPartNameCodeNew.Enabled       = false;

                        sPartNameNew.Items.Clear();
                        sPartNameNew.ResetText();
                        sPartNameNew.Items.Add(item.Value);
                        sPartNameNew.SelectedIndex = 0;
                        sPartNameNew.Enabled       = false;

                        break;
                    }
                }

                subpartSifrarnik.Clear();
                subpartSifrarnik = qc.GetSubPartNamesAllSifrarnikSortByName(sCategory.SelectedItem.ToString(), sPartName.SelectedItem.ToString());

                sSubPartName.ResetText();
                sSubPartName.Items.Clear();

                long bigest = 0;
                foreach (KeyValuePair <long, String> key in subpartSifrarnik)
                {
                    sSubPartName.Items.Add(key.Value);
                    if (bigest < key.Key)
                    {
                        bigest = key.Key;
                    }
                }
                lastIDSubPart.Text = bigest.ToString();

                for (long i = bigest + 1; i < 1000; i++)
                {
                    sSubPartNameCodeNew.Items.Add(i);
                }
            }
            catch (Exception e1)
            {
                Program.LoadStop();
                new LogWriter(e1);
                MessageBox.Show(e1.Message);
            }
            finally
            {
                PostaviFullCode();
                Program.LoadStop();
            }
        }
Exemplo n.º 10
0
        private void FindPart()
        {
            if (this.textBox1.TextLength > 12)
            {
                try
                {
                    Program.LoadStart();

                    QueryCommands qc          = new QueryCommands();
                    QueryCommands qc1         = new QueryCommands();
                    QueryCommands qc2         = new QueryCommands();
                    List <String> sendArr     = new List <string>();
                    List <String> resultArr   = new List <string>();
                    List <String> resultArr1  = new List <string>();
                    List <String> resultArr2  = new List <string>();
                    List <String> resultArr3  = new List <string>();
                    List <String> resultArrG  = new List <string>();
                    List <String> resultArrNG = new List <string>();

                    ConnectionHelper cn = new ConnectionHelper();

                    for (int i = 1; i <= regionCnt; i++)
                    {
                        Control ctn1 = this.Controls["lblAdd_" + i];
                        Control ctn2 = this.Controls["txtBoxAddNG_" + i];
                        Control ctn3 = this.Controls["txtBoxAddG_" + i];

                        this.Controls.Remove(ctn1);
                        this.Controls.Remove(ctn2);
                        this.Controls.Remove(ctn3);
                    }

                    positionX = 20;
                    //positionY = 100;
                    positionPlusY = 0;

                    resultArr3 = qc.GetAllRegions();

                    PartSifrarnik prt = new PartSifrarnik();
                    this.label7.Text = prt.PartCode.ToString();
                    Company cmpO  = new Company();
                    Company cmpC  = new Company();
                    Boolean cmpOb = false;
                    Boolean cmpCb = false;

                    if (Decoder.GetOwnerCode(textBox1.Text).Equals("01"))
                    {
                        MainCmp mpc = new MainCmp();
                        mpc.GetMainCmpByName(Properties.Settings.Default.CmpName);
                        cmpO  = mpc.MainCmpToCompany();
                        cmpOb = true;
                    }
                    else
                    {
                        cmpOb = cmpO.GetCompanyInfoByCode(Decoder.GetOwnerCode(textBox1.Text));
                    }

                    if (Decoder.GetOwnerCode(textBox1.Text).Equals("01"))
                    {
                        MainCmp mpc = new MainCmp();
                        mpc.GetMainCmpByName(Properties.Settings.Default.CmpName);
                        cmpC  = mpc.MainCmpToCompany();
                        cmpCb = true;
                    }
                    else
                    {
                        cmpCb = cmpC.GetCompanyInfoByCode(Decoder.GetCustomerCode(textBox1.Text));
                    }


                    //if (prt.GetPart(textBox1.Text.Substring(4, 9)) && cmpO.GetCompanyInfoByCode(textBox1.Text.Substring(0, 2)) && cmpC.GetCompanyInfoByCode(textBox1.Text.Substring(2, 2))) //DecoderBB
                    if (prt.GetPart(Decoder.GetFullPartCodeStr(textBox1.Text)) && cmpOb && cmpCb)
                    {
                        this.textBox2.ResetText();
                        this.textBox2.Text = prt.FullName;
                        ////this.label18.Text = string.Format("{0:0000 000 000 000}", long.Parse(this.textBox1.Text));
                        this.label18.Text = this.textBox1.Text;
                        this.label7.Text  = cmpO.Name;
                        this.label8.Text  = cmpC.Name;
                        this.label9.Text  = cmpO.Code;
                        this.label10.Text = cmpC.Code;
                        this.label11.Text = prt.CategoryName;
                        this.label12.Text = prt.PartName;
                        this.label13.Text = string.Format("{0:000}", (prt.CategoryCode / 1000000));
                        this.label14.Text = string.Format("{0:000}", (prt.PartCode / 1000));
                        this.label15.Text = prt.SubPartName;
                        this.label16.Text = string.Format("{0:000}", prt.SubPartCode);

                        this.label21.Text = string.Format("{0:C}", prt.PriceInKn);
                        this.label22.Text = string.Format("{0:C}", prt.PriceOutKn);
                        var culture = new CultureInfo("de-DE");
                        this.label25.Text = string.Format(culture, "{0:C}", prt.PriceInEur);
                        this.label26.Text = string.Format(culture, "{0:C}", prt.PriceOutEur);
                        this.label29.Text = prt.PartNumber;
                        sendArr.Clear();
                        resultArr          = qc.InTransport(WorkingUser.Username, WorkingUser.Password, long.Parse(label18.Text.Trim()));
                        this.label30.Text  = resultArr[0] == "nok" ? "0" : resultArr[0];
                        this.label32.Text  = prt.Packing;
                        this.textBox3.Text = "*" + this.label18.Text + "*";

                        regionCnt = (resultArr3.Count() / 3);
                        int j  = 1;
                        int jj = 0;

                        for (int i = 1; i <= regionCnt; i++)
                        {
                            if (!resultArr3[j].Equals("O"))
                            {
                                Label lblAdd = new Label();
                                this.Controls.Add(lblAdd);
                                lblAdd.Size     = new Size(50, 20);
                                positionY       = this.panel21.Bounds.Bottom + 40 + positionPlusY;// + (40 * i);
                                lblAdd.Location = new Point(positionX, positionY);
                                lblAdd.Font     = new Font(lblAdd.Font, FontStyle.Bold);
                                lblAdd.Name     = "lblAdd_" + i;
                                lblAdd.Text     = resultArr3[j] + " - " + resultArr3[j - 1];

                                TextBox txtBoxAddG = new TextBox();
                                this.Controls.Add(txtBoxAddG);

                                txtBoxAddG.Size      = new Size(60, 60);
                                positionY            = this.panel21.Bounds.Bottom + 60 + positionPlusY;// + (40 * i);
                                txtBoxAddG.Location  = new Point(positionX, positionY);
                                txtBoxAddG.BackColor = Color.LightGreen;
                                txtBoxAddG.TextAlign = HorizontalAlignment.Center;
                                txtBoxAddG.ReadOnly  = true;
                                resultArrG.Clear();
                                sendArr.Clear();

                                if (resultArr3[jj + 1].Equals("S"))
                                {
                                    resultArrG = qc.PartsCntGS(WorkingUser.Username, WorkingUser.Password, long.Parse(label18.Text.Trim()));
                                }
                                else
                                {
                                    resultArrG = qc.PartsCntG(WorkingUser.Username, WorkingUser.Password, long.Parse(label18.Text.Trim()), long.Parse(resultArr3[jj].Trim()));
                                }

                                if (resultArr3[jj + 1].Equals("S"))
                                {
                                    txtBoxAddG.Name = "txtBoxAddSG_" + i;
                                }
                                else
                                {
                                    txtBoxAddG.Name = "txtBoxAddG_" + i;
                                }

                                txtBoxAddG.Text = resultArrG[0] == "nok" ? "" : resultArrG[0].Equals("0") ? "" : resultArrG[0];
                                if (!txtBoxAddG.Text.Equals(""))
                                {
                                    totalG = totalG + int.Parse(txtBoxAddG.Text);
                                }

                                TextBox txtBoxAddNG = new TextBox();
                                this.Controls.Add(txtBoxAddNG);

                                txtBoxAddNG.Size      = new Size(60, 60);
                                positionX             = txtBoxAddG.Bounds.Right + 10;
                                txtBoxAddNG.Location  = new Point(positionX, positionY);
                                txtBoxAddNG.BackColor = Color.LightCoral;
                                txtBoxAddNG.TextAlign = HorizontalAlignment.Center;
                                txtBoxAddNG.ReadOnly  = true;
                                resultArrNG.Clear();
                                sendArr.Clear();

                                if (resultArr3[jj + 1].Equals("S"))
                                {
                                    resultArrNG = qc.PartsCntNGS(WorkingUser.Username, WorkingUser.Password, long.Parse(label18.Text.Trim()));
                                }
                                else
                                {
                                    resultArrNG = qc.PartsCntNG(WorkingUser.Username, WorkingUser.Password, long.Parse(label18.Text.Trim()), long.Parse(resultArr3[jj].Trim()));
                                }

                                if (resultArr3[jj + 1].Equals("S"))
                                {
                                    txtBoxAddNG.Name = "txtBoxAddSNG_" + i;
                                }
                                else
                                {
                                    txtBoxAddNG.Name = "txtBoxAddNG_" + i;
                                }

                                txtBoxAddNG.Text = resultArrNG[0] == "nok" ? "" : resultArrNG[0].Equals("0") ? "" : resultArrNG[0];
                                if (!txtBoxAddNG.Text.Equals(""))
                                {
                                    totalNG = totalNG + int.Parse(txtBoxAddNG.Text);
                                }

                                txtBoxAddNG.Click += new EventHandler(showList);
                                txtBoxAddG.Click  += new EventHandler(showList);

                                positionX = positionX + 80;

                                if ((positionX + 150) >= ClientRectangle.Width)
                                {
                                    positionPlusY = positionPlusY + 50;
                                    positionX     = 20;
                                }
                            }
                            j  = j + 3;
                            jj = jj + 3;
                        }
                        textBox4.Text = totalG.ToString();
                        textBox5.Text = totalNG.ToString();
                    }
                    else
                    {
                        clearME();
                    }
                }
                catch (Exception e1)
                {
                    new LogWriter(e1);
                    MessageBox.Show(e1.Message);
                    clearME();
                    return;
                }
                finally
                {
                    Program.LoadStop();
                    this.Focus();
                }
            }
        }
Exemplo n.º 11
0
        private void button2_Click(object sender, EventArgs e)
        {
            ///////////////// LogMe ////////////////////////
            String    function = this.GetType().FullName + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name;
            String    usedQC   = "Save to db";
            String    data     = "";
            String    Result   = "";
            LogWriter lw       = new LogWriter();

            ////////////////////////////////////////////////
            ///

            IUSNumber = "";

            if (this.label2.Text.Equals("Name"))
            {
                Result = "Please select company, nothing done.";
                lw.LogMe(function, usedQC, data, Result);
                MessageBox.Show(Result);
                textBox1.SelectAll();
                isFocused = true;
                textBox1.Focus();
                isFocused = false;
            }
            else if (this.listView1.Items.Count == 0)
            {
                Result = "There is no items in list, nothing done.";
                lw.LogMe(function, usedQC, data, Result);
                MessageBox.Show(Result);
                textBox1.SelectAll();
                isFocused = true;
                textBox1.Focus();
                isFocused = false;
            }
            else
            {
                //List<Part> listOfOtpPartsPrimka = new List<Part>();
                MainCmp mpc = new MainCmp();
                mpc.GetMainCmpByName(Properties.Settings.Default.CmpName);
                cmpR.Clear();
                cmpR = mpc.MainCmpToCompany();

                if (cmpS.GetCompanyByName(label2.Text.Trim()))
                {
                    try
                    {
                        List <String>    arr = new List <string>();
                        ConnectionHelper cn  = new ConnectionHelper();
                        using (SqlConnection cnnIUS = cn.Connect(WorkingUser.Username, WorkingUser.Password))
                        {
                            if (cn.TestConnection(cnnIUS))
                            {
                                //Provjera da li se dijelovi nalaze u mom skladistu
                                QueryCommands qc = new QueryCommands();

                                for (int i = 0; i < listView1.Items.Count; i++) // vec imam provjeru gore kod unosa ali neka ostane(tamo je po imenu)
                                {
                                    if (qc.GetPartIDCompareCodeSNCNStorageState(WorkingUser.Username, WorkingUser.Password,
                                                                                long.Parse(listView1.Items[i].SubItems[2].Text),
                                                                                listView1.Items[i].SubItems[3].Text,
                                                                                listView1.Items[i].SubItems[4].Text,
                                                                                WorkingUser.RegionID, "ng")[0].Equals("nok"))
                                    {
                                        data   = listView1.Items[i].SubItems[2].Text + "\n on position " + (listView1.Items[i].Index + 1);
                                        Result = "In your storage does not exist NG part with: \n\n Code: " + listView1.Items[i].SubItems[2].Text + "\n on position " + (listView1.Items[i].Index + 1) + "\n\nNothing Done.";
                                        lw.LogMe(function, usedQC, data, Result);
                                        MessageBox.Show(Result);
                                        textBox1.SelectAll();
                                        isFocused = true;
                                        textBox1.Focus();
                                        isFocused = false;
                                        return;
                                    }
                                }

                                //Provjera i spremanje u bazu
                                List <String> allRegions = new List <string>();
                                allRegions = qc.GetAllRegions();

                                int index = resultArrC.FindIndex(resultArrC => resultArrC.Name.Equals(label2.Text));

                                List <Part> partList    = new List <Part>();
                                String      napomenaIUS = textBox4.Text;

                                for (int i = 0; i < listView1.Items.Count; i++)
                                {
                                    PartSifrarnik tempSifPart = new PartSifrarnik();
                                    Part          tempPart    = new Part();

                                    foreach (Part part in partsArr)
                                    {
                                        tempSifPart.GetPart(Decoder.GetFullPartCodeStr(listView1.Items[i].SubItems[2].Text));

                                        if (part.PartialCode == tempSifPart.FullCode && part.SN.ToUpper().Equals(listView1.Items[i].SubItems[3].Text.ToUpper()) && part.CN.ToUpper().Equals(listView1.Items[i].SubItems[4].Text.ToUpper()) && !partList.Contains(part))
                                        {
                                            tempPart           = part;
                                            tempPart.StorageID = WorkingUser.RegionID;
                                            tempPart.State     = "sng";
                                            tempPart.CompanyO  = Decoder.GetOwnerCode(listView1.Items[i].SubItems[2].Text);
                                            tempPart.CompanyC  = Decoder.GetCustomerCode(listView1.Items[i].SubItems[2].Text);
                                            break;
                                        }
                                    }

                                    String tmpResult = qc.GetListPartsByPartIDFromParts(tempPart.PartID)[0];

                                    if (tmpResult.Equals("nok"))
                                    {
                                        data   = listView1.Items[i].SubItems[2].Text + "\n on position " + (listView1.Items[i].Index + 1);
                                        Result = "There is no NG part in your storage with: \n\n Code: " + listView1.Items[i].SubItems[2].Text + "\n on position " + (listView1.Items[i].Index + 1) + ". \n\nNothing Done.";
                                        lw.LogMe(function, usedQC, data, Result);
                                        MessageBox.Show(Result);
                                        textBox1.SelectAll();
                                        isFocused = true;
                                        textBox1.Focus();
                                        isFocused = false;
                                        return;
                                    }
                                    else
                                    {
                                        tempPart.PartID = long.Parse(tmpResult);
                                        partList.Add(tempPart);
                                    }
                                }

                                IUSNumber = qc.IUSPrebaciUServis(WorkingUser.Username, WorkingUser.Password, partList, WorkingUser.RegionID, cmpS.ID, napomenaIUS);
                                if (!IUSNumber.Equals("nok"))
                                {
                                    partsArr = partsArr.Except(partList).ToList();

                                    PovijestLog pl = new PovijestLog();

                                    if (Program.SaveDocumentsPDF)
                                    {
                                        saveToPDF(partList);
                                    }

                                    if (pl.SaveToPovijestLog(partList, DateTime.Now.ToString("dd.MM.yy."), napomenaIUS, cmpS.Name, "", "", "IUS " + Properties.Settings.Default.ShareDocumentName, "sng"))
                                    {
                                        Properties.Settings.Default.ShareDocumentName = "";

                                        Result = "DONE, document nbr. IUS '" + IUSNumber + "'.";
                                        lw.LogMe(function, usedQC, data, Result);
                                        MessageBox.Show(Result);

                                        partListPrint.Clear();
                                        partListPrint.AddRange(partList);

                                        isIUSSaved = true;
                                        listView1.Clear();
                                        listView1.View = View.Details;

                                        listView1.Columns.Add("RB");
                                        listView1.Columns.Add("Name");
                                        listView1.Columns.Add("Code");
                                        listView1.Columns.Add("SN");
                                        listView1.Columns.Add("CN");
                                        listView1.Columns.Add("Condition");
                                        textBox4.Clear();
                                        napomenaIUSPrint = napomenaIUS;
                                    }
                                    else
                                    {
                                        Result = "DONE, document nbr. 'IUS " + IUSNumber + "', but not saved in PL.";
                                        lw.LogMe(function, usedQC, data, Result);
                                        MessageBox.Show(Result);

                                        partListPrint.Clear();
                                        partListPrint.AddRange(partList);

                                        isIUSSaved = true;
                                        listView1.Clear();
                                        listView1.View = View.Details;

                                        listView1.Columns.Add("RB");
                                        listView1.Columns.Add("Name");
                                        listView1.Columns.Add("Code");
                                        listView1.Columns.Add("SN");
                                        listView1.Columns.Add("CN");
                                        listView1.Columns.Add("Condition");
                                        textBox4.Clear();
                                        napomenaIUSPrint = napomenaIUS;
                                    }
                                }
                                else
                                {
                                    Result = "Unknown error in QUERY.";
                                    lw.LogMe(function, usedQC, data, Result);
                                    MessageBox.Show(Result);
                                    napomenaIUSPrint = "";
                                    isIUSSaved       = false;
                                }
                                //}
                            }
                            cnnIUS.Close();
                        }
                    }
                    catch (Exception e1)
                    {
                        new LogWriter(e1);
                        MessageBox.Show(e1.Message);
                        textBox1.SelectAll();
                        isFocused = true;
                        textBox1.Focus();
                        isFocused = false;
                    }
                }
                this.printPrewBT.Enabled = isIUSSaved;
            }
        }
Exemplo n.º 12
0
        private void button2_Click(object sender, EventArgs e)
        {
            Program.SaveStart();

            ///////////////// LogMe ////////////////////////
            String    function = this.GetType().FullName + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name;
            String    usedQC   = "Save to db";
            String    data     = "";
            String    Result   = "";
            LogWriter lw       = new LogWriter();

            ////////////////////////////////////////////////
            ///

            PrimkaNumber = "";

            if (this.label2.Text.Equals("Name"))
            {
                Result = "Please select company, nothing done.";
                lw.LogMe(function, usedQC, data, Result);

                Program.SaveStop();
                MessageBox.Show(Result);

                textBox1.SelectAll();
                textBox1.Focus();
            }
            else if (this.listView1.Items.Count == 0)
            {
                Result = "There is no items in list, nothing done.";
                lw.LogMe(function, usedQC, data, Result);

                Program.SaveStop();
                MessageBox.Show(Result);

                textBox1.SelectAll();
                textBox1.Focus();
            }
            else
            {
                List <Part> listOfOtpPartsFromOTP = new List <Part>();
                //List<Part> listOfOtpPartsPrimka = new List<Part>();
                MainCmp mpc = new MainCmp();
                mpc.GetMainCmpByName(Properties.Settings.Default.CmpName);
                cmpR.Clear();
                cmpR = mpc.MainCmpToCompany();

                if (cmpS.GetCompanyByName(label2.Text.Trim()))
                {
                    try
                    {
                        List <String>    arr = new List <string>();
                        SqlCommand       commandPR;
                        String           queryPR;
                        ConnectionHelper cn = new ConnectionHelper();
                        using (SqlConnection cnnPR = cn.Connect(WorkingUser.Username, WorkingUser.Password))
                        {
                            if (cn.TestConnection(cnnPR))
                            {
                                //Provjera da li se dijelovi nalaze u mom skladistu
                                QueryCommands qc = new QueryCommands();

                                for (int i = 0; i < listView1.Items.Count; i++) // vec imam provjeru gore kod unosa ali neka ostane(tamo je po imenu)
                                {
                                    if (!listView1.Items[i].SubItems[3].Text.Equals("") && !listView1.Items[i].SubItems[4].Text.Equals(""))
                                    {
                                        if (!qc.GetPartIDCompareCodeSNCNStorage(WorkingUser.Username, WorkingUser.Password,
                                                                                long.Parse(listView1.Items[i].SubItems[2].Text),
                                                                                listView1.Items[i].SubItems[3].Text,
                                                                                listView1.Items[i].SubItems[4].Text,
                                                                                WorkingUser.RegionID)[0].Equals("nok"))
                                        {
                                            data   = listView1.Items[i].SubItems[2].Text + ", " + listView1.Items[i].Index + 1;
                                            Result = "In your storage, part with: \n\n Code: " + listView1.Items[i].SubItems[2].Text + "\n on position " + (listView1.Items[i].Index + 1) + "\n, already exist in DB.\n\nNothing Done.";
                                            lw.LogMe(function, usedQC, data, Result);

                                            Program.SaveStop();
                                            MessageBox.Show(Result);

                                            textBox1.SelectAll();
                                            textBox1.Focus();
                                            return;
                                        }
                                    }
                                }

                                //Provjera i spremanje u bazu

                                List <String> allRegions = new List <string>();
                                allRegions = qc.GetAllRegions();

                                int index = resultArrC.FindIndex(resultArrC => resultArrC.Name.Equals(label2.Text));

                                if (resultArrC[index].RegionID != Properties.Settings.Default.OstaliIDRegion &&
                                    resultArrC[index].RegionID != Properties.Settings.Default.TransportIDRegion)
                                {
                                    queryPR   = "Select RegionIDOut from Transport where RegionIDIn = " + WorkingUser.RegionID + " and UsersUserIDIn is NULL";
                                    commandPR = new SqlCommand(queryPR, cnnPR);
                                    commandPR.ExecuteNonQuery();
                                    SqlDataReader dataReader = commandPR.ExecuteReader();
                                    dataReader.Read();

                                    if (dataReader.HasRows)
                                    {
                                        do
                                        {
                                            openedTransactionSenderRegions.Add(dataReader["RegionIDOut"].ToString());
                                        } while (dataReader.Read());
                                        dataReader.Close();
                                    }
                                    else
                                    {
                                        data   = resultArrC[index].RegionID + ", " + Properties.Settings.Default.OstaliIDRegion + ", " + resultArrC[index].RegionID + ", " + Properties.Settings.Default.TransportIDRegion;
                                        Result = "From selected region nothing is sent to you. \n\n Nothing Done.";
                                        lw.LogMe(function, usedQC, data, Result);

                                        Program.SaveStop();
                                        MessageBox.Show(Result);

                                        textBox1.SelectAll();
                                        textBox1.Focus();
                                        return;
                                    }

                                    for (int i = 0; i < listView1.Items.Count; i++) // vec imam provjeru gore kod unosa ali neka ostane(tamo je po imenu)
                                    {
                                        //long test = long.Parse(listView1.Items[i].SubItems[2].Text.Substring(4)); //DecoderBB
                                        long test = Decoder.GetFullPartCodeLng(listView1.Items[i].SubItems[2].Text);
                                        if (!resultArrSearchCode.Contains(test.ToString()))
                                        {
                                            data   = test.ToString() + ", " + listView1.Items[i].Index + 1;
                                            Result = "There is no part in 'Sifrarnik' with code, = " + test.ToString() + "\n" + "on position " + (listView1.Items[i].Index + 1) + "  \n\n Nothing Done.";
                                            lw.LogMe(function, usedQC, data, Result);

                                            Program.SaveStop();
                                            MessageBox.Show(Result);

                                            textBox1.SelectAll();
                                            textBox1.Focus();
                                            return;
                                        }
                                    }

                                    //Provjera da li sam odabrao dobru tvrtku koja salje
                                    Boolean exist = false;
                                    for (int j = 0; j < openedTransactionSenderRegions.Count; j++)
                                    {
                                        if (cmpS.RegionID.ToString().Equals(openedTransactionSenderRegions[j]))
                                        {
                                            exist = true;
                                            break;
                                        }
                                    }

                                    if (!exist)
                                    {
                                        data   = cmpS.RegionID.ToString();
                                        Result = "Please select right company! \n\n Nothing done.";
                                        lw.LogMe(function, usedQC, data, Result);

                                        Program.SaveStop();
                                        MessageBox.Show(Result);

                                        textBox1.SelectAll();
                                        textBox1.Focus();
                                        return;
                                    }

                                    openedOTP = qc.GetAllOpenedOTP(WorkingUser.Username, WorkingUser.Password, WorkingUser.RegionID);
                                    long selectedOTP = 0;

                                    if (openedOTP[0].Equals("nok"))
                                    {
                                        data   = openedOTP[0].ToString();
                                        Result = "There is no opened documents for you!";
                                        lw.LogMe(function, usedQC, data, Result);

                                        Program.SaveStop();
                                        MessageBox.Show(Result);

                                        textBox1.SelectAll();
                                        textBox1.Focus();
                                        return;
                                    }

                                    using (Selector selector = new Selector())
                                    {
                                        selector.SetLabelText          = "Please select receiving document";
                                        selector.SetComboBoxStringList = openedOTP;
                                        selector.ShowDialog();

                                        if (selector.GetOTPValue > 0)
                                        {
                                            selectedOTP = selector.GetOTPValue;
                                        }
                                        else
                                        {
                                            data   = selectedOTP.ToString();
                                            Result = "Please select valid receiving document! \n\n Nothing done.";
                                            lw.LogMe(function, usedQC, data, Result);

                                            Program.SaveStop();
                                            MessageBox.Show(Result);

                                            textBox1.SelectAll();
                                            textBox1.Focus();
                                            return;
                                        }
                                    }

                                    Part otpParts = new Part();
                                    listOfOtpPartsFromOTP = otpParts.GetListOfPartsOTPParts(selectedOTP);

                                    int     counterLP = listOfOtpPartsFromOTP.Count;
                                    int     counterLV = listView1.Items.Count;
                                    Boolean same      = false;
                                    for (int i = 0; i < counterLP; i++)
                                    {
                                        for (int ii = 0; ii < counterLV; ii++)
                                        {
                                            if (listOfOtpPartsFromOTP[i].CodePartFull == long.Parse(listView1.Items[ii].SubItems[2].Text) &&
                                                listOfOtpPartsFromOTP[i].SN.ToUpper().Equals(listView1.Items[ii].SubItems[3].Text.ToUpper()) &&
                                                listOfOtpPartsFromOTP[i].CN.ToUpper().Equals(listView1.Items[ii].SubItems[4].Text.ToUpper()))
                                            {
                                                same = true;
                                                break;
                                            }
                                            else
                                            {
                                                same = false;
                                                data = listOfOtpPartsFromOTP[i].CodePartFull.ToString() + ", " + long.Parse(listView1.Items[ii].SubItems[2].Text).ToString() + ", " +
                                                       listOfOtpPartsFromOTP[i].SN.ToUpper().Equals(listView1.Items[ii].SubItems[3].Text.ToUpper()).ToString() + ", " + listOfOtpPartsFromOTP[i].CN.ToUpper().Equals(listView1.Items[ii].SubItems[4].Text.ToUpper()).ToString();
                                            }
                                        }
                                        if (!same)
                                        {
                                            break;
                                        }
                                    }

                                    if (!same || counterLP != counterLV)
                                    {
                                        Result = "Receiving document and sending document items do not match ! \n\n Nothing done.";
                                        lw.LogMe(function, usedQC, data, Result);

                                        Program.SaveStop();
                                        MessageBox.Show(Result);

                                        textBox1.SelectAll();
                                        textBox1.Focus();
                                        return;
                                    }

                                    PrimkaNumber = qc.PRIMUnesiUredajeDaSuPrimljeniInnner(WorkingUser.Username, WorkingUser.Password, listOfOtpPartsFromOTP, cmpS.RegionID, cmpR.RegionID, selectedOTP, textBox4.Text);
                                    if (!PrimkaNumber.Equals("nok"))
                                    {
                                        PovijestLog pl    = new PovijestLog();
                                        Boolean     saved = false;
                                        for (int k = 0; k < listOfOtpPartsFromOTP.Count; k++)
                                        {
                                            List <Part> tempPart = new List <Part>();
                                            tempPart.Clear();
                                            tempPart.Add(listOfOtpPartsFromOTP[k]);
                                            if (pl.SaveToPovijestLog(tempPart, DateTime.Now.ToString("dd.MM.yy."), textBox4.Text, cmpS.Name, "", "", "PRIM " + Properties.Settings.Default.ShareDocumentName, tempPart[0].State))
                                            {
                                                saved = true;
                                                Properties.Settings.Default.ShareDocumentName = "";
                                            }
                                            else
                                            {
                                                saved = false;
                                                break;
                                            }
                                        }

                                        if (saved)
                                        {
                                            data   = PrimkaNumber;
                                            Result = "DONE, document nbr. 'PRIM " + PrimkaNumber + "'.";
                                            lw.LogMe(function, usedQC, data, Result);

                                            Program.SaveStop();
                                            MessageBox.Show(Result);

                                            isPrimkaSaved = true;
                                            listView1.Clear();
                                            listView1.View = View.Details;

                                            partListPrint.Clear();
                                            partListPrint.AddRange(listOfOtpPartsFromOTP);
                                            //partListPrint = listOfOtpPartsPrimka;

                                            listView1.Columns.Add("RB");
                                            listView1.Columns.Add("Name");
                                            listView1.Columns.Add("Code");
                                            listView1.Columns.Add("SN");
                                            listView1.Columns.Add("CN");
                                            listView1.Columns.Add("Condition");
                                            textBox4.Clear();
                                        }
                                        else
                                        {
                                            data   = PrimkaNumber;
                                            Result = "DONE, document nbr. 'PRIM " + PrimkaNumber + "', but not saved in PL.";
                                            lw.LogMe(function, usedQC, data, Result);

                                            Program.SaveStop();
                                            MessageBox.Show(Result);

                                            listView1.Clear();
                                            listView1.View = View.Details;

                                            partListPrint.Clear();
                                            partListPrint.AddRange(listOfOtpPartsFromOTP);
                                            //partListPrint = listOfOtpPartsPrimka;

                                            listView1.Columns.Add("RB");
                                            listView1.Columns.Add("Name");
                                            listView1.Columns.Add("Code");
                                            listView1.Columns.Add("SN");
                                            listView1.Columns.Add("CN");
                                            listView1.Columns.Add("Condition");
                                            textBox4.Clear();
                                        }
                                    }
                                    else
                                    {
                                        Result = "Unknown error in QUERYinner.";
                                        lw.LogMe(function, usedQC, data, Result);

                                        Program.SaveStop();
                                        MessageBox.Show(Result);

                                        isPrimkaSaved = false;
                                    }
                                }
                                else if (resultArrC[index].RegionID == Properties.Settings.Default.OstaliIDRegion)
                                {
                                    List <Part> partList     = new List <Part>();
                                    String      napomenaPRIM = napomenaPRIMPrint = textBox4.Text;

                                    for (int i = 0; i < listView1.Items.Count; i++)
                                    {
                                        PartSifrarnik tempSifPart = new PartSifrarnik();
                                        Part          tempPart    = new Part();

                                        //tempSifPart.GetPart(listView1.Items[i].SubItems[2].Text.Substring(4)); //DecoderBB
                                        tempSifPart.GetPart(Decoder.GetFullPartCodeStr(listView1.Items[i].SubItems[2].Text));

                                        tempPart.PartialCode = tempSifPart.FullCode;
                                        tempPart.SN          = listView1.Items[i].SubItems[3].Text;
                                        tempPart.CN          = listView1.Items[i].SubItems[4].Text;
                                        tempPart.DateIn      = DateTime.Now.ToString("dd.MM.yy.");
                                        tempPart.StorageID   = WorkingUser.RegionID;
                                        tempPart.State       = listView1.Items[i].SubItems[5].Text;
                                        //tempPart.CompanyO = listView1.Items[i].SubItems[2].Text.Substring(0, 2); //DecoderBB
                                        tempPart.CompanyO = Decoder.GetOwnerCode(listView1.Items[i].SubItems[2].Text);
                                        //tempPart.CompanyC = listView1.Items[i].SubItems[2].Text.Substring(2, 2); //DecoderBB
                                        tempPart.CompanyC = Decoder.GetCustomerCode(listView1.Items[i].SubItems[2].Text);

                                        partList.Add(tempPart);
                                    }

                                    PrimkaNumber = qc.PRIMUnesiUredajeDaSuPrimljeni(WorkingUser.Username, WorkingUser.Password, partList, WorkingUser.RegionID, cmpS.ID, napomenaPRIM);
                                    if (!PrimkaNumber.Equals("nok"))
                                    {
                                        PovijestLog pl    = new PovijestLog();
                                        Boolean     saved = false;
                                        for (int k = 0; k < partList.Count; k++)
                                        {
                                            List <Part> tempPart = new List <Part>();
                                            tempPart.Clear();
                                            tempPart.Add(partList[k]);
                                            if (pl.SaveToPovijestLog(tempPart, DateTime.Now.ToString("dd.MM.yy."), napomenaPRIM, cmpS.Name, "", "", "PRIM " + Properties.Settings.Default.ShareDocumentName, tempPart[0].State))
                                            {
                                                saved = true;
                                            }
                                            else
                                            {
                                                saved = false;
                                                Properties.Settings.Default.ShareDocumentName = "";
                                                break;
                                            }
                                        }

                                        if (Program.SaveDocumentsPDF)
                                        {
                                            saveToPDF(partList);
                                        }

                                        if (saved)
                                        {
                                            data   = PrimkaNumber;
                                            Result = "DONE, document nbr. 'PRIM " + PrimkaNumber + "'.";
                                            lw.LogMe(function, usedQC, data, Result);

                                            Program.SaveStop();
                                            MessageBox.Show(Result);

                                            partListPrint.Clear();
                                            partListPrint.AddRange(partList);

                                            isPrimkaSaved = true;
                                            listView1.Clear();
                                            listView1.View = View.Details;

                                            listView1.Columns.Add("RB");
                                            listView1.Columns.Add("Name");
                                            listView1.Columns.Add("Code");
                                            listView1.Columns.Add("SN");
                                            listView1.Columns.Add("CN");
                                            listView1.Columns.Add("Condition");
                                            textBox4.Clear();
                                            napomenaPRIMPrint = napomenaPRIM;
                                        }
                                        else
                                        {
                                            data   = PrimkaNumber;
                                            Result = "DONE, document nbr. 'PRIM " + PrimkaNumber + "', but not saved in PL.";
                                            lw.LogMe(function, usedQC, data, Result);

                                            Program.SaveStop();
                                            MessageBox.Show(Result);

                                            partListPrint.Clear();
                                            partListPrint.AddRange(partList);

                                            isPrimkaSaved = true;
                                            listView1.Clear();
                                            listView1.View = View.Details;

                                            listView1.Columns.Add("RB");
                                            listView1.Columns.Add("Name");
                                            listView1.Columns.Add("Code");
                                            listView1.Columns.Add("SN");
                                            listView1.Columns.Add("CN");
                                            listView1.Columns.Add("Condition");
                                            textBox4.Clear();
                                            napomenaPRIMPrint = napomenaPRIM;
                                        }
                                    }
                                    else
                                    {
                                        Result = "Unknown error in QUERYinner.";
                                        lw.LogMe(function, usedQC, data, Result);

                                        Program.SaveStop();
                                        MessageBox.Show(Result);

                                        napomenaPRIMPrint = "";
                                        isPrimkaSaved     = false;
                                    }
                                }
                            }
                            cnnPR.Close();
                        }
                    }
                    catch (Exception e1)
                    {
                        Program.SaveStop();

                        new LogWriter(e1);
                        MessageBox.Show(e1.Message);
                        textBox1.SelectAll();
                        textBox1.Focus();
                    }
                }
                this.printPrewBT.Enabled           = isPrimkaSaved;
                this.selectPrinterPrintBtn.Enabled = isPrimkaSaved;
            }
            Program.SaveStop();
        }
Exemplo n.º 13
0
        public void Print(PrintPageEventArgs e)
        {
            e.HasMorePages = false;

            Font fontID32 = new Font("IDAutomationHC39M", 11, FontStyle.Regular);

            int sredina = 0;
            int kocka   = 200;

            int pozicija1 = 0;
            int pozicija2 = 0;
            int pozicija3 = 0;

            long userIDinfo = 0;

            int moveBy = 5;

            PageSettings page = GetPrinterPageInfo();

            RectangleF area    = page.PrintableArea;
            Rectangle  bounds  = page.Bounds;
            Margins    margins = page.Margins;

            //inace po defaultu 100
            margins.Left   = 75;
            margins.Right  = 75;
            margins.Top    = 50;
            margins.Bottom = 75;

            kursorVer = margins.Top;
            kursorHor = bounds.Right - margins.Right;

            try
            {
                string workingStr   = "";
                float  measureStr   = 0;
                float  measureField = 0;

                //Color cl = ColorTranslator.FromHtml("#1B75BC");
                Color cl = ColorTranslator.FromHtml("#0174AA");

                Brush brushBlue  = new SolidBrush(cl);
                Brush brushBlack = Brushes.Black;
                Brush brushWhite = Brushes.White;
                Brush brushGrey  = Brushes.Gray;

                using (img)
                {
                    Pen bijeliPen = new Pen(Brushes.White);
                    Pen crniPen   = new Pen(Brushes.Black);

                    //TICKET ID
                    workingStr = "SERVICE REPORT";
                    measureStr = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA18).Width);
                    //kursorHor -= (int)measureStr -50;
                    kursorHor = bounds.Right - margins.Right - (int)measureStr;
                    e.Graphics.DrawString(workingStr, fntA18, brushBlue, kursorHor, kursorVer);

                    moveBy    = fntA18.Height;
                    kursorHor = margins.Left;
                    Rectangle rect = new Rectangle(kursorHor, kursorVer, kocka, moveBy);
                    e.Graphics.FillRectangle(brushBlue, rect);
                    e.Graphics.DrawRectangle(crniPen, rect);

                    workingStr = tidRN.TicketID.ToString() + "_" + tidRN.CCN + "_" + tidRN.CID;
                    Font tmp = fitFontSize(e, workingStr, 12, kocka);
                    measureStr = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, tmp).Width);
                    sredina    = (margins.Left + (kocka / 2) - (int)(measureStr / 2));
                    kursorHor -= (int)measureStr - 50;
                    e.Graphics.DrawString(workingStr, tmp, brushWhite, sredina, kursorVer + 5);
                    kursorVer += (moveBy);

                    e.Graphics.DrawLine(new Pen(Brushes.Black), new Point(margins.Left, kursorVer), new Point(bounds.Right - margins.Right, kursorVer));



                    //PRVI DETALJI
                    moveBy          = fntA10b.Height;
                    kursorVer      += (moveBy);
                    kursorHor       = pozicija1 = margins.Left + 5;
                    kursorHorPodaci = margins.Left + 80;

                    ///////////////////////////////////////
                    workingStr = "Tech.:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, kursorHor, kursorVer);

                    if (tidRN.UserIDUnio != 0)
                    {
                        userIDinfo = tidRN.UserIDUnio;
                    }
                    else if (tidRN.UserIDZavrsio != 0)
                    {
                        userIDinfo = tidRN.UserIDZavrsio;
                    }
                    else if (tidRN.UserIDPoceo != 0)
                    {
                        userIDinfo = tidRN.UserIDPoceo;
                    }
                    else if (tidRN.UserIDDrive != 0)
                    {
                        userIDinfo = tidRN.UserIDDrive;
                    }
                    else if (tidRN.UserIDPreuzeo != 0)
                    {
                        userIDinfo = tidRN.UserIDPreuzeo;
                    }
                    else
                    {
                        userIDinfo = tidRN.UserIDSastavio;
                    }

                    workingStr = userIDinfo.ToString();
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, kursorHorPodaci, kursorVer);

                    workingStr = "CONTACT DATA";
                    e.Graphics.DrawString(workingStr, fntA10b, brushGrey, 480, kursorVer);
                    kursorVer += (moveBy);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "Date:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, kursorHor, kursorVer);

                    if (tidRN.DatReport.Equals(""))
                    {
                        workingStr = DateTime.Now.ToString("dd.MM.yy.");
                    }
                    else
                    {
                        workingStr = tidRN.DatReport;
                    }

                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, kursorHorPodaci, kursorVer);

                    workingStr = "Phone:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushGrey, 500, kursorVer);
                    workingStr = Properties.Settings.Default.CmpPhone;
                    e.Graphics.DrawString(workingStr, fntA10, brushGrey, 560, kursorVer);
                    kursorVer += (moveBy);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "Time:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, kursorHor, kursorVer);

                    if (tidRN.VriReport.Equals(""))
                    {
                        workingStr = DateTime.Now.ToString("HH:mm");
                    }
                    else
                    {
                        workingStr = tidRN.VriReport;
                    }

                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, kursorHorPodaci, kursorVer);

                    workingStr = "Support:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushGrey, 500, kursorVer);
                    workingStr = Properties.Settings.Default.SupportEmail;
                    e.Graphics.DrawString(workingStr, fntA10, brushGrey, 560, kursorVer);
                    kursorVer += (moveBy);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "Region:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, kursorHor, kursorVer);

                    if (tidRN.UserIDUnio != 0)
                    {
                        userIDinfo = tidRN.UserIDUnio;
                    }
                    else if (tidRN.UserIDPreuzeo != 0)
                    {
                        userIDinfo = tidRN.UserIDPreuzeo;
                    }
                    else
                    {
                        userIDinfo = tidRN.UserIDSastavio;
                    }

                    workingStr = qc.RegionInfoByUserID(userIDinfo)[2];
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, kursorHorPodaci, kursorVer);

                    workingStr = "Info:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushGrey, 500, kursorVer);
                    workingStr = Properties.Settings.Default.CmpEmail;
                    e.Graphics.DrawString(workingStr, fntA10, brushGrey, 560, kursorVer);
                    kursorVer += (moveBy * 2);
                    ///////////////////////////////////////


                    //DRUGI KVADRAT
                    moveBy    = fntA18.Height;
                    kursorHor = margins.Left;
                    rect      = new Rectangle(kursorHor, kursorVer, kocka, moveBy);
                    e.Graphics.FillRectangle(brushBlue, rect);
                    e.Graphics.DrawRectangle(crniPen, rect);

                    workingStr = "CUSTOMER INQURY";
                    measureStr = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA12).Width);
                    sredina    = (margins.Left + (kocka / 2) - (int)(measureStr / 2));
                    kursorHor -= (int)measureStr - 50;
                    e.Graphics.DrawString(workingStr, fntA12, brushWhite, sredina, kursorVer + 5);
                    kursorVer += (moveBy);

                    e.Graphics.DrawLine(new Pen(Brushes.Black), new Point(margins.Left, kursorVer), new Point(bounds.Right - margins.Right, kursorVer));



                    //DRUGI DETALJI
                    moveBy          = fntA10b.Height;
                    kursorVer      += (moveBy);
                    kursorHor       = margins.Left + 5;
                    kursorHorPodaci = margins.Left + 80;

                    int triPlaces = (bounds.Right - margins.Left - margins.Right) / 3;
                    //pozicija1 = 0; //vec postavljeno gore
                    pozicija2 = margins.Left + triPlaces;
                    pozicija3 = margins.Left + (triPlaces * 2);

                    ///////////////////////////////////////
                    workingStr = "Date:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    workingStr = tidRN.DatPrijave;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 70, kursorVer);

                    workingStr = "Contact:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija2, kursorVer);
                    workingStr = tidRN.Prijavio;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija2 + 70, kursorVer);

                    workingStr = "Time SLA:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija3, kursorVer);
                    workingStr = tidRN.VriSLA;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija3 + 70, kursorVer);

                    kursorVer += (moveBy);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "Time:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    workingStr = tidRN.VriPrijave;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 70, kursorVer);

                    workingStr = "Priority:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija2, kursorVer);
                    workingStr = tidRN.Prio.ToString();
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija2 + 70, kursorVer);

                    workingStr = "Date SLA:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija3, kursorVer);
                    workingStr = tidRN.DatSLA;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija3 + 70, kursorVer);

                    kursorVer += (moveBy);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "Branch:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    workingStr = tidRN.Filijala;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 70, kursorVer);

                    workingStr = "Cst.ID:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija2, kursorVer);
                    workingStr = tidRN.TvrtkeID.ToString();
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija2 + 70, kursorVer);

                    workingStr = "Cst.Name:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija3, kursorVer);
                    workingStr = qc.CompanyInfoByID(WorkingUser.Username, WorkingUser.Password, tidRN.TvrtkeID)[1];
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija3 + 70, kursorVer);

                    kursorVer += (moveBy * 2);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "Problem:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    workingStr = tidRN.NazivUredaja;

                    measureStr   = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA10).Width);
                    measureField = bounds.Right - margins.Right - (pozicija1 + 80);
                    workingStr   = ReziMe(measureStr, measureField, workingStr, e, fntA10);
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 80, kursorVer);

                    kursorVer += (moveBy * 3);

                    workingStr = "Description:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    workingStr = tidRN.OpisKvara;

                    measureStr   = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA10).Width);
                    measureField = bounds.Right - margins.Right - (pozicija1 + 80);
                    workingStr   = ReziMe(measureStr, measureField, workingStr, e, fntA10);
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 80, kursorVer);

                    kursorVer += (moveBy * 3);
                    ///////////////////////////////////////



                    //TRECI KVADRAT
                    moveBy    = fntA18.Height;
                    kursorHor = margins.Left;
                    rect      = new Rectangle(kursorHor, kursorVer, kocka, moveBy);
                    e.Graphics.FillRectangle(brushBlue, rect);
                    e.Graphics.DrawRectangle(crniPen, rect);

                    workingStr = "SERVICE DATA";
                    measureStr = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA12).Width);
                    sredina    = (margins.Left + (kocka / 2) - (int)(measureStr / 2));
                    kursorHor -= (int)measureStr - 50;
                    e.Graphics.DrawString(workingStr, fntA12, brushWhite, sredina, kursorVer + 5);
                    kursorVer += (moveBy);

                    e.Graphics.DrawLine(new Pen(Brushes.Black), new Point(margins.Left, kursorVer), new Point(bounds.Right - margins.Right, kursorVer));

                    //TRECI DETALJI
                    moveBy          = fntA10b.Height;
                    kursorVer      += (moveBy);
                    kursorHor       = margins.Left + 5;
                    kursorHorPodaci = margins.Left + 80;

                    ///////////////////////////////////////
                    workingStr = "Date:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    workingStr = tidRN.DatZavrsio;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 70, kursorVer);

                    workingStr = "Work start:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija2, kursorVer);
                    workingStr = tidRN.VriPoceo;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija2 + 75, kursorVer);

                    workingStr = "Error Code:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija3, kursorVer);
                    workingStr = tidRN.Rn.ErrorCode;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija3 + 75, kursorVer);

                    kursorVer += (moveBy);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "Start time:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    workingStr = tidRN.VriDrive;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 70, kursorVer);

                    workingStr = "Work end:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija2, kursorVer);
                    workingStr = tidRN.VriZavrsio;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija2 + 75, kursorVer);

                    workingStr = "ID number:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija3, kursorVer);
                    workingStr = tidRN.TicketID.ToString();
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija3 + 75, kursorVer);

                    kursorVer += (moveBy * 2);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "Description:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    workingStr = tidRN.Rn.DescriptionRN;

                    measureStr   = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA10).Width);
                    measureField = bounds.Right - margins.Right - (pozicija1 + 80);
                    workingStr   = ReziMe(measureStr, measureField, workingStr, e, fntA10);
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 80, kursorVer);

                    kursorVer += (moveBy * 3);
                    ///////////////////////////////////////


                    //CETVRTI KVADRAT
                    moveBy    = fntA18.Height;
                    kursorHor = margins.Left;
                    rect      = new Rectangle(kursorHor, kursorVer, kocka, moveBy);
                    e.Graphics.FillRectangle(brushBlue, rect);
                    e.Graphics.DrawRectangle(crniPen, rect);

                    workingStr = "SERVICE DATA";
                    measureStr = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA12).Width);
                    sredina    = (margins.Left + (kocka / 2) - (int)(measureStr / 2));
                    kursorHor -= (int)measureStr - 50;
                    e.Graphics.DrawString(workingStr, fntA12, brushWhite, sredina, kursorVer + 5);
                    kursorVer += (moveBy);

                    e.Graphics.DrawLine(new Pen(Brushes.Black), new Point(margins.Left, kursorVer), new Point(bounds.Right - margins.Right, kursorVer));

                    //CETVRTI DETALJI
                    moveBy          = fntA10b.Height;
                    kursorVer      += (moveBy);
                    kursorHor       = margins.Left + 5;
                    kursorHorPodaci = margins.Left + 80;

                    if (tidRN.Rn.PartListNew.Count > 1 || tidRN.Rn.PartListOld.Count > 1) //TODO vjerovatno treba druga provjera, odnosno pamtiti na kojem smo jer ovako ide u beskonacnost
                    {
                        e.HasMorePages = true;
                    }

                    pozicija2 = bounds.Right / 2;

                    ///////////////////////////////////////
                    workingStr = "S/N new:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    if (tidRN.Rn.PartListNew.Count > 0)
                    {
                        workingStr = tidRN.Rn.PartListNew[partsCount].SN;
                        e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 70, kursorVer);
                    }

                    workingStr = "S/N old:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija2, kursorVer);
                    if (tidRN.Rn.PartListOld.Count > 0)
                    {
                        workingStr = tidRN.Rn.PartListOld[partsCount].SN;
                        e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija2 + 70, kursorVer);
                    }

                    kursorVer += (moveBy);
                    ///////////////////////////////////////

                    String kodNew = "";
                    String kodOld = "";

                    ///////////////////////////////////////
                    workingStr = "Code new:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    if (tidRN.Rn.PartListNew.Count > 0)
                    {
                        kodNew = String.Format("{0000000000000:0}", tidRN.Rn.PartListNew[partsCount].CodePartFull.ToString());

                        workingStr = kodNew;
                        e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 70, kursorVer);
                    }

                    workingStr = "Code old:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija2, kursorVer);
                    if (tidRN.Rn.PartListOld.Count > 0)
                    {
                        kodOld = String.Format("{0000000000000:0}", tidRN.Rn.PartListOld[partsCount].CodePartFull.ToString());

                        workingStr = kodOld;
                        e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija2 + 70, kursorVer);
                    }

                    kursorVer += (moveBy);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "Name new:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);

                    String fullNameNew = "";

                    if (tidRN.Rn.PartListNew.Count > 0)
                    {
                        PartSifrarnik prNew = qc.PartInfoByFullCodeSifrarnik(tidRN.Rn.PartListNew[partsCount].PartialCode);
                        workingStr  = prNew.SubPartName;
                        fullNameNew = prNew.CategoryName + " " + prNew.PartName;
                        e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 70, kursorVer);
                    }

                    workingStr = "Name old:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija2, kursorVer);
                    if (tidRN.Rn.PartListOld.Count > 0)
                    {
                        PartSifrarnik prOld = qc.PartInfoByFullCodeSifrarnik(tidRN.Rn.PartListOld[partsCount].PartialCode);
                        workingStr = prOld.SubPartName;
                        e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija2 + 70, kursorVer);
                    }

                    kursorVer += (moveBy);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "CCN:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    workingStr = tidRN.CCN;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 70, kursorVer);

                    workingStr = "CID:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija2, kursorVer);
                    workingStr = tidRN.CID;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija2 + 70, kursorVer);

                    kursorVer += (moveBy);
                    ///////////////////////////////////////

                    ///////////////////////////////////////
                    workingStr = "Part name:";
                    e.Graphics.DrawString(workingStr, fntA10b, brushBlack, pozicija1, kursorVer);
                    workingStr = fullNameNew;
                    e.Graphics.DrawString(workingStr, fntA10, brushBlack, pozicija1 + 70, kursorVer);

                    kursorVer += (moveBy * 2);
                    ///////////////////////////////////////

                    //BARKODOVI
                    ///////////////////////////////////////
                    workingStr = "S/N new";
                    e.Graphics.DrawString(workingStr, fntA8, brushGrey, pozicija1, kursorVer);

                    workingStr = "S/N old";
                    e.Graphics.DrawString(workingStr, fntA8, brushGrey, pozicija2, kursorVer);


                    kursorVer += 14;

                    if (tidRN.Rn.PartListNew.Count > 0)
                    {
                        workingStr = "*" + tidRN.Rn.PartListNew[partsCount].SN.ToString() + "*";
                        e.Graphics.DrawString(workingStr, fontID32, brushBlack, pozicija1, kursorVer);
                    }

                    if (tidRN.Rn.PartListOld.Count > 0)
                    {
                        workingStr = "*" + tidRN.Rn.PartListOld[partsCount].SN.ToString() + "*";
                        e.Graphics.DrawString(workingStr, fontID32, brushBlack, pozicija2, kursorVer);
                    }
                    ///////////////////////////////////////

                    kursorVer += 80;

                    ///////////////////////////////////////
                    workingStr = "Device code new";
                    e.Graphics.DrawString(workingStr, fntA8, brushGrey, pozicija1, kursorVer);

                    workingStr = "Device code old";
                    e.Graphics.DrawString(workingStr, fntA8, brushGrey, pozicija2, kursorVer);


                    kursorVer += 14;

                    if (tidRN.Rn.PartListNew.Count > 0)
                    {
                        workingStr = "*" + kodNew + "*";
                        e.Graphics.DrawString(workingStr, fontID32, brushBlack, pozicija1, kursorVer);
                    }

                    if (tidRN.Rn.PartListOld.Count > 0)
                    {
                        workingStr = "*" + kodOld + "*";
                        e.Graphics.DrawString(workingStr, fontID32, brushBlack, pozicija2, kursorVer);
                    }
                    ///////////////////////////////////////

                    kursorVer += 80;

                    ///////////////////////////////////////
                    workingStr = "Customer Call Nr.";
                    e.Graphics.DrawString(workingStr, fntA8, brushGrey, pozicija1, kursorVer);

                    workingStr = "Call ID";
                    e.Graphics.DrawString(workingStr, fntA8, brushGrey, pozicija2, kursorVer);


                    kursorVer += 14;

                    workingStr = "*" + tidRN.CCN.ToString() + "*";
                    e.Graphics.DrawString(workingStr, fontID32, brushBlack, pozicija1, kursorVer);

                    workingStr = "*" + tidRN.CID.ToString() + "*";
                    e.Graphics.DrawString(workingStr, fontID32, brushBlack, pozicija2, kursorVer);
                    ///////////////////////////////////////


                    //FOOTER
                    ///////////////////////////////////////
                    kursorVer = bounds.Bottom - (margins.Bottom + 25);

                    e.Graphics.DrawLine(new Pen(Brushes.Black, 1.5f), new Point(bounds.Right - margins.Right - 250, kursorVer), new Point(bounds.Right - margins.Right, kursorVer));
                    workingStr = "Signature";
                    e.Graphics.DrawString(workingStr, fntA9, brushGrey, bounds.Right - margins.Right - 246, kursorVer - fntA9.Height);

                    kursorVer += 25;

                    imgW = imgW / 4;                       //80
                    imgH = (int)((double)imgW / imgScale); //75 //40
                    e.Graphics.DrawImage(img, margins.Left, kursorVer, imgW, imgH);

                    sredina = bounds.Right / 2;

                    workingStr = "RadniNalogReport";
                    measureStr = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA10).Width);
                    e.Graphics.DrawString(workingStr, fntA10, brushGrey, sredina - (measureStr / 2), kursorVer);

                    workingStr = DateTime.Now.ToString("HH:mm dd.MM.yy.");
                    measureStr = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA10).Width);
                    e.Graphics.DrawString(workingStr, fntA10, brushGrey, bounds.Right - margins.Right - measureStr, kursorVer);

                    kursorVer += fntA10.Height;

                    workingStr = Properties.Settings.Default.CmpWWW;
                    measureStr = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA10).Width);
                    e.Graphics.DrawString(workingStr, fntA10, brushGrey, sredina - (measureStr / 2), kursorVer);

                    workingStr = "Page " + pgNumber;
                    measureStr = (float)Math.Ceiling(e.Graphics.MeasureString(workingStr, fntA10).Width);
                    e.Graphics.DrawString(workingStr, fntA10, brushGrey, bounds.Right - margins.Right - measureStr, kursorVer);
                }

                if (e.HasMorePages)
                {
                    partsCount += 1;
                    pgNumber   += 1;
                    return;
                }

                partsCount = 0;
                pgNumber   = 1;

                return;
            }
            catch (Exception e1)
            {
                //TODO: Treba logirati gresku
                MessageBox.Show(e1.Message);

                partsCount = 0;
                pgNumber   = 1;
            }
        }
Exemplo n.º 14
0
        private void Ponuda_Load(object sender, EventArgs e)
        {
            offer.Naplaceno  = 0;
            offer.Operater   = WorkingUser.UserID.ToString();
            offer.RacunID    = 0;
            offer.Storno     = 0;
            offer.Konverzija = 1;
            if (radioButtonENG.Checked)
            {
                offer.NacinPlacanja = Properties.Settings.Default.PaymentForm;
                vat = Properties.Settings.Default.TAX2 / 100;
            }
            else
            {
                offer.NacinPlacanja = Properties.Settings.Default.NacinPlacanja;
                vat = Properties.Settings.Default.TAX1 / 100;
            }


            offer.Id        = ponudaID = offer.GetNewOfferNumber();
            InvNbrLB.Text   = offer.IDLongtoString(ponudaID);
            obrJedLB.Text   = Properties.Settings.Default.ObracunskaJedinica.ToString();
            QuantityTB.Text = "1";

            backgroundWorker1.WorkerReportsProgress      = true;
            backgroundWorker1.WorkerSupportsCancellation = true;

            mainCmp.GetMainCmpInfoByID(Properties.Settings.Default.CmpID);

            exchng = qc.CurrentExchangeRate();

            ech       = double.Parse(exchng[3]);
            offer.Eur = (decimal)ech;
            echDate   = exchng[1];


            ExchangeLB.Text      = String.Format("{0,000:N3}", ech);
            offer.DanTecaja      = EchDateLB.Text = echDate;
            offer.DatumIzdano    = DateTime.Now.ToString("dd.MM.yy.");
            offer.DatumNaplaceno = "01.01.01.";

            DateTime dt = DateTime.Today.AddDays(valuta);

            ValutaLB.Text = valuta.ToString() + " (" + dt.ToString("dd.MM.yy.") + ")";
            offer.Valuta  = valuta;

            if (backgroundWorker1.IsBusy != true)
            {
                backgroundWorker1.RunWorkerAsync();
            }

            listView1.View = View.Details;

            listView1.Columns.Add("RB");
            listView1.Columns.Add("PART NAME");
            listView1.Columns.Add("PART CODE");
            listView1.Columns.Add("PRICE");
            listView1.Columns.Add("WORK TIME");
            listView1.Columns.Add("REBATE");
            listView1.Columns.Add("AMOUNT");
            listView1.Columns.Add("REBATE PRICE");
            listView1.Columns.Add("TOTAL");

            for (int i = 0; i < listView1.Columns.Count; i++)
            {
                listView1.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent);
                listView1.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.HeaderSize);
            }

            try
            {
                Company tempCmp = new Company();
                cmpList = tempCmp.GetAllCompanyInfoSortByName();

                if (cmpList.Count > 0)
                {
                    foreach (Company cmp in cmpList)
                    {
                        CustomerCB.Items.Add(cmp.Name);
                    }
                }

                PartSifrarnik tempSifPart = new PartSifrarnik();
                sifrarnikList = tempSifPart.GetPartsAllSifrarnikSortByFullName();

                if (sifrarnikList.Count > 0)
                {
                    foreach (PartSifrarnik sif in sifrarnikList)
                    {
                        PartNameCB.Items.Add(sif.FullName);
                    }
                }
            }
            catch (Exception e1)
            {
                new LogWriter(e1);

                Program.LoadStop();
                this.Focus();
            }
            Program.LoadStop();
            this.Focus();
        }