private void button1_Click(object sender, EventArgs e) { ///////////////// LogMe //////////////////////// String function = this.GetType().FullName + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name; String usedQC = "Add to list"; String data = ""; String Result = ""; LogWriter lw = new LogWriter(); //////////////////////////////////////////////// /// try { ListViewItem lvi1 = new ListViewItem(); rb = listView1.Items.Count + 1; lvi1.Text = rb.ToString(); //if ((sifrarnikArr.IndexOf((long.Parse((textBox1.Text).Substring(4)).ToString()))) < 0) //DecoderBB if ((sifrarnikArr.IndexOf(Decoder.GetFullPartCodeStr(textBox1.Text))) < 0) { data = textBox1.Text; Result = "Selected code does not exist in DB."; lw.LogMe(function, usedQC, data, Result); MessageBox.Show(Result); textBox1.SelectAll(); return; } addToList(true, long.Parse(textBox1.Text), textBox2.Text, textBox3.Text); //lvi1.SubItems.Add(sifrarnikArr[sifrarnikArr.IndexOf((long.Parse((textBox1.Text).Substring(4)).ToString())) - 1]); //DecoderBB if (data.Equals("")) { data = textBox1.Text + ", " + textBox2.Text + ", " + textBox3.Text + ", ng"; } else { data = data + Environment.NewLine + " " + textBox1.Text + ", " + textBox2.Text + ", " + textBox3.Text + ", ng"; } } catch (Exception e1) { new LogWriter(e1); MessageBox.Show(e1.Message); } }
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); } }
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; } }
private void addToList(Boolean clear, long mCode, String mSN, String mCN) { ///////////////// LogMe //////////////////////// String function = this.GetType().FullName + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name; String usedQC = "Add to list"; String data = ""; String Result = ""; LogWriter lw = new LogWriter(); //////////////////////////////////////////////// /// try { ListViewItem lvi1 = new ListViewItem(); rb = listView1.Items.Count + 1; lvi1.Text = rb.ToString(); //if ((sifrarnikArr.IndexOf((long.Parse((textBox1.Text).Substring(4)).ToString()))) < 0) //DecoderBB if ((sifrarnikArr.IndexOf(Decoder.GetFullPartCodeStr(mCode.ToString()))) < 0) { data = mCode.ToString(); Result = "Selected code does not exist in DB."; lw.LogMe(function, usedQC, data, Result); MessageBox.Show(Result); textBox1.SelectAll(); return; } //lvi1.SubItems.Add(sifrarnikArr[sifrarnikArr.IndexOf((long.Parse((textBox1.Text).Substring(4)).ToString())) - 1]); //DecoderBB lvi1.SubItems.Add(sifrarnikArr[sifrarnikArr.IndexOf(Decoder.GetFullPartCodeStr(mCode.ToString())) - 1]); lvi1.SubItems.Add(mCode.ToString()); lvi1.SubItems.Add(mSN); lvi1.SubItems.Add(mCN); lvi1.SubItems.Add("ng"); if (listView1.Items.Count > 1) { listView1.EnsureVisible(listView1.Items.Count - 1); } listView1.Items.Add(lvi1); if (data.Equals("")) { data = mCode.ToString() + ", " + mSN + ", " + mCN + ", g"; } else { data = data + Environment.NewLine + " " + mCode.ToString() + ", " + mSN + ", " + mCN + ", g"; } } catch (Exception e1) { new LogWriter(e1); MessageBox.Show(e1.Message); } for (int i = 0; i < listView1.Columns.Count; i++) { listView1.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent); listView1.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.HeaderSize); } if (clear) { textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); } textBox1.SelectAll(); isFocused = true; textBox1.Focus(); isFocused = false; Result = "Added"; lw.LogMe(function, usedQC, data, Result); SystemSounds.Hand.Play(); }
private void listView1_DoubleClick(object sender, EventArgs e) { ///////////////// LogMe //////////////////////// String function = this.GetType().FullName + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name; String usedQC = "PRIM Selected"; String data = ""; String Result = ""; LogWriter lw = new LogWriter(); //////////////////////////////////////////////// /// this.label7.Text = "Working..."; this.Refresh(); br.Clear(); if (!pictureOn) { Thread myThread = new Thread(fillSifrarnik); myThread.Start(); } listView2.Items.Clear(); listView2.Refresh(); this.label5.Text = ""; List <long> prtList = new List <long>(); List <Part> parts = new List <Part>(); long primID; int rb; Part prt = new Part(); var item = listView1.SelectedItems; if (item.Count == 0) { this.label7.Text = ""; return; } int index = item[0].Index; long threadCmpCode = long.Parse(item[0].SubItems[2].Text); Thread myThreadCmp = new Thread(() => fillCmp(threadCmpCode)); myThreadCmp.Start(); primID = long.Parse(item[0].SubItems[1].Text); prtList = qc.GetAllpartIDByPrimID(primID); this.label5.Text = "Selected PRIM: " + primID.ToString(); datumIzradeM = userArr[(5 * index) + 2]; izradioUserM = userArr[(5 * index) + 4]; QueryCommands qc4 = new QueryCommands(); List <String> test = qc4.User(WorkingUser.Username, WorkingUser.Password, izradioUserM); if (!test[0].Equals("nok")) { izradioRegijaM = test[7]; } else { MessageBox.Show("I cant find user. Provjeri sto ne radi dobro na primci od germanie"); return; } if (prtList[0] == -1) { data = primID.ToString(); Result = "Can not find parts by given primID."; lw.LogMe(function, usedQC, data, Result); MessageBox.Show(Result); return; } try { rb = listView2.Items.Count + 1; parts = prt.GetListOfPartsFromPartsPartsPoslanoByID(prtList); if (parts.Count == 0) { data = primID.ToString(); Result = "Selected PRIM (" + primID.ToString() + ") does not exist or do not have parts."; lw.LogMe(function, usedQC, data, Result); MessageBox.Show(Result); return; } var groupedPartsListSN = parts.GroupBy(c => c.CodePartFull).Select(grp => grp.ToList()).ToList(); int i = 0; for (int k = 0; k < groupedPartsListSN.Count; k++) { String name = (sifrarnikArr[sifrarnikArr.IndexOf(Decoder.GetFullPartCodeStr(parts[i].PartialCode.ToString())) - 1]); for (i = 0; i < groupedPartsListSN[k].Count; i++) { ListViewItem lvi2 = new ListViewItem(rb.ToString()); lvi2.SubItems.Add(name); lvi2.SubItems.Add(groupedPartsListSN[k][i].CodePartFull.ToString()); lvi2.SubItems.Add(groupedPartsListSN[k][i].SN); lvi2.SubItems.Add(groupedPartsListSN[k][i].CN); if (listView2.Items.Count > 1) { listView2.EnsureVisible(listView2.Items.Count - 1); } listView2.Items.Add(lvi2); rb = listView2.Items.Count + 1; if (data.Equals("")) { data = groupedPartsListSN[k][i].CodePartFull.ToString() + ", " + groupedPartsListSN[k][i].SN + ", " + groupedPartsListSN[k][i].CN; } else { data = data + Environment.NewLine + " " + groupedPartsListSN[k][i].CodePartFull.ToString() + ", " + groupedPartsListSN[k][i].SN + ", " + groupedPartsListSN[k][i].CN; } } } } catch (Exception e1) { new LogWriter(e1); MessageBox.Show(e1.Message); } for (int i = 0; i < listView2.Columns.Count; i++) { listView2.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent); listView2.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.HeaderSize); } PRIMNumber = string.Format("{0:00/000}", primID); partListPrint.AddRange(parts); napomenaPRIMPrint = item[0].SubItems[4].Text; ////////////////// TODO ODKOMENTIRAJ AKO BUDES NA PRIMCI IMAO ISPIS FILIJALE/////////////////// //if (!item[0].SubItems[6].Text.Equals("")) // br.GetFilByID(long.Parse(item[0].SubItems[7].Text)); br.FilID = 0; if (!cmpR.Name.Equals("")) { this.label8.Text = "cmpR: OK"; } else { this.label8.Text = "cmpR: NOK"; } if (!cmpS.Name.Equals("")) { this.label9.Text = "cmpS: OK"; } else { this.label9.Text = "cmpS: NOK"; } if (br.FilID != 0) { this.label10.Text = "br: OK"; } else { this.label10.Text = "br: NOK"; } Result = "Added"; lw.LogMe(function, usedQC, data, Result); SystemSounds.Hand.Play(); this.label7.ResetText(); }
private void addToList(Boolean remove, Boolean update, OfferParts invPrt) { ///////////////// LogMe //////////////////////// String function = this.GetType().FullName + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name; String usedQC = "Add to list"; String data = ""; String Result = ""; LogWriter lw = new LogWriter(); //////////////////////////////////////////////// /// decimal cijena = 0; decimal popust = 0; decimal partTotal = 0; decimal partsTotal = 0; //decimal cijena = decimal.Parse(CheckIfKNZero(tempSifPart)); if (!remove) { decimal kn = tempSifPart.PriceOutKn; decimal eur = tempSifPart.PriceOutEur; if (radioButtonENG.Checked) { cijena = eur > 0 ? eur : kn / (decimal)ech; } else { cijena = kn > 0 ? kn : eur * (decimal)ech; } popust = invPrt.Rabat; partTotal = invPrt.PartTotalPrice(cijena, popust, invPrt.VrijemeRada); partsTotal = partTotal * invPrt.Kolicina; //TOTAL += partsTotal; TOTALTAXBASE += partsTotal; TOTALTAX = TOTALTAXBASE * vat; TOTAL = TOTALTAX + TOTALTAXBASE; offer.Iznos = TOTAL; } else { cijena = decimal.Parse(invPrt.IznosTotal); //TOTAL += partsTotal; TOTALTAXBASE -= cijena; TOTALTAX = TOTALTAXBASE * vat; TOTAL = TOTALTAX + TOTALTAXBASE; offer.Iznos = TOTAL; } try { String dd; if (!remove && !update) { ListViewItem lvi1 = new ListViewItem(); rb = listView1.Items.Count + 1; lvi1.Text = rb.ToString(); lvi1.SubItems.Add(tempSifPart.FullName); lvi1.SubItems.Add(mainCmp.Code.ToString() + customerCmp.Code.ToString() + Decoder.GetFullPartCodeStr(tempSifPart.FullCode)); lvi1.SubItems.Add(String.Format("{0:0.00}", cijena)); lvi1.SubItems.Add(invPrt.VrijemeRada); lvi1.SubItems.Add(String.Format("{0:0.00}", invPrt.Rabat)); lvi1.SubItems.Add(String.Format("{0:#0}", invPrt.Kolicina)); lvi1.SubItems.Add(String.Format("{0:0.00}", partTotal)); lvi1.SubItems.Add(String.Format("{0:0.00}", partsTotal)); if (listView1.Items.Count > 1) { listView1.EnsureVisible(listView1.Items.Count - 1); } listView1.Items.Add(lvi1); dd = tempSifPart.FullName + ", " + Decoder.GetFullPartCodeStr(tempSifPart.FullCode.ToString()) + ", " + tempSifPart.PriceInKn.ToString() + ", " + invPrt.VrijemeRada + ", " + invPrt.Rabat.ToString() + ", " + invPrt.Kolicina.ToString() + ", " + partTotal + ", " + partsTotal + ", " + TOTAL.ToString(); invPrt.IznosPart = String.Format("{0:N2}", cijena); invPrt.IznosRabat = String.Format("{0:N2}", partTotal); invPrt.IznosTotal = String.Format("{0:N2}", partsTotal); if (data.Equals("")) { data = dd; } else { data = data + Environment.NewLine + " " + dd; } } else { dd = tempSifPart.FullName + ", " + Decoder.GetFullPartCodeStr(tempSifPart.FullCode.ToString()) + ", " + tempSifPart.PriceInKn.ToString() + ", " + invPrt.VrijemeRada + ", " + invPrt.Rabat.ToString() + ", " + invPrt.Kolicina.ToString() + ", " + partTotal + ", " + partsTotal + ", " + TOTAL.ToString(); if (data.Equals("")) { data = dd; } else { data = data + Environment.NewLine + " " + dd; } } if (radioButtonENG.Checked) { TaxBaseLB.Text = String.Format("{0:0.00}", TOTALTAXBASE * (decimal)ech); VATLB.Text = String.Format("{0:0.00}", TOTALTAX * (decimal)ech); TotalEURLB.Text = String.Format("{0:0.00}", TOTAL); TotalKNLB.Text = String.Format("{0:0.00}", (TOTAL * (decimal)ech)); } else { TaxBaseLB.Text = String.Format("{0:0.00}", TOTALTAXBASE); VATLB.Text = String.Format("{0:0.00}", TOTALTAX); TotalEURLB.Text = String.Format("{0:0.00}", TOTAL / (decimal)ech); TotalKNLB.Text = String.Format("{0:0.00}", TOTAL); } } catch (Exception e1) { new LogWriter(e1); MessageBox.Show(e1.Message); } for (int i = 0; i < listView1.Columns.Count; i++) { listView1.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent); listView1.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.HeaderSize); } //if (clear) //{ // textBox1.Clear(); // textBox2.Clear(); // textBox3.Clear(); //} //textBox1.SelectAll(); //isFocused = true; //textBox1.Focus(); //isFocused = false; Result = "Added"; lw.LogMe(function, usedQC, data, Result); SystemSounds.Hand.Play(); }