private void button2_Click(object sender, EventArgs e) { if (textBox1.Text == "" || dataGridView1.SelectedRows.Count == 0) { MessageBox.Show("Podaj jakąś ilość lub zaznacz jeden wiersz do poprawy!!!", "błąd"); return; } double.TryParse(textBox1.Text, out double qty); string litm = (string)dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[2].Value; string nazwa = (string)dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[3].Value; var db2008 = new DB2008DataContext(); var kod = (from c in db2008.SLOWNIK_1s where c.IMLITM.Trim() == litm.Trim() select c).First(); DialogResult dl = MessageBox.Show("Czy zaksięgować detal\n" + litm + " " + nazwa + "\n RW na magazyn " + mag_zlec + " Ilosc:" + qty.ToString() + " " + kod.JM_PROD.Trim(), "ksiegowanie", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dl == DialogResult.No) { return; } db_raportyDataContext db = new db_raportyDataContext(); var nrec = new IPO_ZDAWKA_PW(); nrec.Czy_korygowany = true; nrec.Data_utworzenia_poz = DateTime.Now; nrec.Ilosc = qty; nrec.IPO_ID_POZYCJI = -1; nrec.ITM = kod.IMITM.ToString(); nrec.typ = 0; nrec.Zaksiegowany_JDE = false; nrec.JM = kod.JM_PROD.Trim(); nrec.Kod_zlecenia_klienta = kod_wyr; nrec.Koszt_IPO = 0; nrec.Koszt_mat_IPO = 0; nrec.Magazyn_IPO = mag_zlec; nrec.Nazwa_pozycji = nazwa; nrec.Nr_indeksu = litm; nrec.Nr_zam_klienta = litm; nrec.Nr_seryjny = ""; nrec.Nr_zam_klienta = ""; nrec.Nr_zlecenia_IPO = nr_zlec; nrec.Powod_korekty = "DODANE " + DateTime.Now.ToString() + " RĘCZNIE PRZEZ " + user_name; nrec.RW_PW = "RW"; db.IPO_ZDAWKA_PWs.InsertOnSubmit(nrec); db.SubmitChanges(); this.textBox1.Text = ""; this.Update_grid(); }
private void button1_Click(object sender, EventArgs e) //zapisz rekord { WebReference.Service1 srv = new WebReference.Service1(); var db2008 = new DB2008DataContext(); var kod = (from c in db2008.SLOWNIK_1s where c.IMLITM.Trim() == litm.Trim() select c).First(); db_raportyDataContext db = new db_raportyDataContext(); var nrec = new IPO_ZDAWKA_PW(); nrec.Czy_korygowany = true; nrec.Data_utworzenia_poz = DateTime.Now; nrec.Ilosc = qty; nrec.IPO_ID_POZYCJI = -1; nrec.ITM = itm.ToString(); nrec.typ = 0; nrec.Zaksiegowany_JDE = false; nrec.JM = kod.JM_PROD.Trim(); nrec.Kod_zlecenia_klienta = tb_litm.Text; nrec.Koszt_IPO = 0; nrec.Koszt_mat_IPO = 0; nrec.Magazyn_IPO = mag_dom; nrec.Nazwa_pozycji = lb_nazwa.Text; nrec.Nr_indeksu = litm; nrec.Nr_zam_klienta = litm; nrec.Nr_seryjny = ""; nrec.Nr_zam_klienta = ""; nrec.Nr_zlecenia_IPO = nr_zlec_IPO; nrec.Powod_korekty = "DODANE " + DateTime.Now.ToString() + " RĘCZNIE PRZEZ " + user; if (rbPW.Checked) { nrec.RW_PW = "PW"; } if (rbRW.Checked) { nrec.RW_PW = "RW"; } if (rbPU.Checked) { nrec.RW_PW = "PU"; nrec.typ = 1; } db.IPO_ZDAWKA_PWs.InsertOnSubmit(nrec); db.SubmitChanges(); this.Close(); }
public static List <ListaBOM> Get_Bom_1Level(int wyrob_s, double qty, int level, int main_grp) { List <ListaBOM> boms = new List <ListaBOM>(); using (DB2008DataContext db = new DB2008DataContext()) { var bom = from c in db.IPO_Rozpis_mats where c.wyrob_s == wyrob_s select c; int _temp_m_grp = 0; foreach (var bt in bom) { ListaBOM b = new ListaBOM(); b.level = level; b.ilosc = (double)bt.ilosc * qty; b.ilosc_norma = (double)bt.ilosc; b.nazwa_s = bt.Nazwa_s; b.nazwa_w = bt.Nazwa_w; b.skl_l = bt.skladnik_l; b.skl_s = (int)bt.skladnik_s; b.wyrob_l = bt.wyrob_l; b.wyrob_s = (int)bt.wyrob_s; b.main_grp = main_grp; if (level == 0) { b.main_grp = ++_temp_m_grp; } var child = from c in db.IPO_Rozpis_mats where c.wyrob_s == bt.skladnik_s select c; if (child.Count() > 0) { b.has_child = true; } else { b.has_child = false; } boms.Add(b); } } return(boms); }
private void button3_Click(object sender, EventArgs e) { DB2008DataContext db = new DB2008DataContext(); WebReference.Service1 srv = new WebReference.Service1(); double.TryParse(this.tb_qty.Text, out qty); int.TryParse(this.tb_nr_zlec.Text, out nr_zlec_IPO); var zlecenie = srv.IPO_GET_ORDER(nr_zlec_IPO); double itm_zl = 0; double.TryParse(zlecenie.item_id, out itm_zl); var mat_itm = from c in db.SLOWNIK_1s where c.IMLITM == this.tb_litm.Text select new { c.IMITM, c.NAZWA, c.KOLOR }; var wyr_itm = from c in db.SLOWNIK_1s where c.IMITM == mat_itm.First().IMITM // where c.IMITM == itm_zl select new { c.IMITM, c.NAZWA, c.KOLOR }; if (mat_itm.Count() == 1 && wyr_itm.Count() == 1 && zlecenie.ipo_order_id > 0) { var mag = from c in db.IPO_MAGAZYN_PODSTAWOWY_PWs where c.LIITM == wyr_itm.First().IMITM select c; mag_dom = mag.First().mag_ipo; lb_mag.Text = mag_dom.Trim(); if (qty != 0 && nr_zlec_IPO != 0) { this.button1.Enabled = true; } lb_nazwa.Text = mat_itm.First().NAZWA; itm = mat_itm.First().IMITM; litm = tb_litm.Text; } }
public static List <ListaBOM> GetBom(int ilosc, string LITM) { DB2008DataContext db = new DB2008DataContext(); var _itm = from c in db.SLOWNIK_1s where c.IMLITM == LITM select c; List <ListaBOM> lista = new List <ListaBOM>(); if (_itm.Count() == 1) { var itm = _itm.First(); lista = BOM.Get_BOM((int)itm.IMITM, ilosc); BOM.Sort_BOM(ref lista); } return(lista); }
public Cardex(string item, string nr_zlec) { InitializeComponent(); var db = new DB2008DataContext(); var dane = from c in db.IPO_CARDEXes orderby c.data_transakcji descending where c.nr_indeksu == item select c; int _nr_zlec; int.TryParse(nr_zlec, out _nr_zlec); if (_nr_zlec != 0) { dane = dane.Where(c => c.nr_zl_DOCO == _nr_zlec); } this.dataGridView1.DataSource = dane; }
private void Korekta_MAG_Load(object sender, EventArgs e) { button2.Enabled = false; db_raportyDataContext db = new db_raportyDataContext(); DB2008DataContext db2008 = new DB2008DataContext(); var rec = (from c in db.IPO_ZDAWKA_PWs where c.ID == id select c).Single(); var stany = from g in db2008.IPO_STANies where g.LITM == rec.Nr_indeksu select new { g.mag_ipo, DOSTEPNE = g.QTY, DO_POBRANIA = "" }; lb_do_rozp.Text = rec.Ilosc.ToString(); DataTable st = LINQResultToDataTable(stany); dg_mag.DataSource = st; dg_mag.Update(); dg_mag.ReadOnly = false; dg_mag.Columns[2].ReadOnly = false; dg_mag.Columns[1].ReadOnly = true; dg_mag.Columns[0].ReadOnly = true; }
public Analiza(string _nr_zlec, string user) { InitializeComponent(); nr_zlec = int.Parse(_nr_zlec); user_name = user; var srv = new WebReference.Service1(); var db = new db_raportyDataContext(); var db2008 = new DB2008DataContext(); var zlecenie = srv.IPO_GET_ORDER(nr_zlec); double itm_zl = 0; double.TryParse(zlecenie.item_id, out itm_zl); var wyr_itm = (from c in db2008.SLOWNIK_1s where c.IMITM == itm_zl select new { c.IMITM, c.NAZWA, c.KOLOR, c.IMLITM }).FirstOrDefault(); kod_wyr = wyr_itm.IMLITM.Trim(); var mag = (from c in db2008.IPO_MAGAZYN_PODSTAWOWY_PWs where c.LIITM == wyr_itm.IMITM select c).FirstOrDefault(); mag_zlec = mag.mag_ipo; Update_grid(); }
private void button1_Click(object sender, EventArgs e) { WebReference.Service1 srv = new WebReference.Service1(); //Dodaj nowy rekord do bazy... DB2008DataContext db2 = new DB2008DataContext(); double il_ok = 0; double il_br = 0; int nr_zlec = 0; string Indeks = ""; double.TryParse(tb_ilosc.Text, out il_ok); double.TryParse(tb_ilosc_brak.Text, out il_br); int.TryParse(tb_nr_zlecenia.Text, out nr_zlec); db_raportyDataContext db = new db_raportyDataContext(); var task_id = db.IPO_GET_TASK_ID().First(); var zlec = srv.IPO_GET_ORDER(nr_zlec); var idx = from c in db2.SLOWNIK_1s where c.IMITM == double.Parse(zlec.item_id) select c; if (idx.Count() == 1) { Indeks = idx.First().IMLITM.Trim(); } if (zlec.ipo_order_id == 0) { MessageBox.Show("Popraw nr zlecenia!!!"); return; } Regex reg = new Regex("[1-9][0-9]-"); if (!reg.IsMatch(tb_opis.Text)) { MessageBox.Show("Popraw opis pracy musi zawierac nr operacji i znak - , np 10-na gotowo"); return; } reg = new Regex("[1-9][0-9][0-9]"); if (!reg.IsMatch(tb_nr_masz.Text)) { MessageBox.Show("Popraw nr maszyny!!! "); return; } IPO_Task tsk = new IPO_Task(); DateTime start = dtp_start_data.Value.Date + dtp_start_czas.Value.TimeOfDay; DateTime stop = dtp_stop_data.Value.Date + dtp_stop_czas.Value.TimeOfDay; if (start > stop) { MessageBox.Show("Popraw daty i godziny!!! Start nie może być poźniej niż stop!!!"); return; } tsk.Czas_planowany = 0; tsk.Czas_realizacji = (int)(stop - start).TotalMinutes; tsk.Czas_start = start; tsk.Czas_stop = stop; tsk.Id_maszyny = tb_nr_masz.Text; tsk.Id_pracownika = ddPracownik.SelectedValue.ToString(); tsk.Pracownik = ddPracownik.Text; if (tb_id_pracownika.Text != "") { string nazwa = srv.IPO_get_user(tb_id_pracownika.Text); tsk.Id_pracownika = tb_id_pracownika.Text; tsk.Pracownik = nazwa; } if (tsk.Pracownik == "BŁĄD!!!") { MessageBox.Show("Popraw Id pracownika!!!"); return; } tsk.Id_zlecenia = nr_zlec; tsk.Ilosc_brak = il_br; tsk.Ilosc_wykonana = il_ok; tsk.Indeks = Indeks; tsk.Indeks_ITM = int.Parse(zlec.item_id); tsk.Task_Id = task_id.IPO_TASK_ID_KOREKTA; tsk.Ilosc_planowana = 0; tsk.Nr_zamowienia = _logged; tsk.Opis_pracy = tb_opis.Text; tsk.Nazwa_operacji = dd_operacja.Text; db.IPO_Tasks.InsertOnSubmit(tsk); db.SubmitChanges(); this.Close(); }
public void Update_grid() { var db1 = new db_raportyDataContext(); var nlinie = from c in db1.IPO_ZDAWKA_PWs where c.Nr_zlecenia_IPO == nr_zlec select c; var n_linie = Analiza_zlec.Lista_pozycji(nr_zlec); double nilosc_zlec = (double)(from c in nlinie where c.RW_PW == "PW" select c.Ilosc).Sum(); label1.Text = kod_wyr + " : " + nilosc_zlec.ToString() + " SZT" + " ; Korekty na magazyn: " + mag_zlec; dataGridView1.DataSource = n_linie; dataGridView1.Update(); return; var srv = new WebReference.Service1(); var db = new db_raportyDataContext(); var db2008 = new DB2008DataContext(); //skasuj stare rozpisy var do_skas = from c in db.IPO_ZDAWKA_PW_NORMAs where c.Nr_zlecenia_IPO == nr_zlec select c; db.IPO_ZDAWKA_PW_NORMAs.DeleteAllOnSubmit(do_skas); db.SubmitChanges(); //znajdz magazyn domyślny dla zlecenia var linie = from c in db.IPO_ZDAWKA_PWs where c.Nr_zlecenia_IPO == nr_zlec select c; //wyceń materiały - nie przejmujemy się jednostkami. foreach (var l in linie) { var tkw = (from c in db.słownik_TKWs where c.Indeks.Trim() == l.Nr_indeksu.Trim() select c.Koszt).FirstOrDefault(); if (l.RW_PW == "PW") { l.Koszt_IPO = Math.Round((double)tkw * (double)l.Ilosc, 3); } if (l.RW_PW == "RW") { l.Koszt_IPO = Math.Round((double)tkw * (double)-l.Ilosc, 3); } if (l.RW_PW == "PU") { l.Koszt_IPO = Math.Round((double)tkw * (double)-l.Ilosc, 3); } db.SubmitChanges(); } double ilosc_zlec = (double)(from c in linie where c.RW_PW == "PW" select c.Ilosc).Sum(); // utwórz zlecenie w tabeli przejściowej. label1.Text = kod_wyr + " : " + ilosc_zlec.ToString() + " SZT" + " ; Korekty na magazyn: " + mag_zlec; srv.Dodaj_rozpis_do_Tabeli(nr_zlec, 0, ilosc_zlec); // wyceń rozpis var linie_norma = from c in db.IPO_ZDAWKA_PW_NORMAs where c.Nr_zlecenia_IPO == nr_zlec && c.RW_PW == "RW" select c; //wyceń materiały - nie przejmujemy się jednostkami. foreach (var l in linie_norma) { var tkw = (from c in db.słownik_TKWs where c.Indeks.Trim() == l.Nr_indeksu.Trim() select c.Koszt).FirstOrDefault(); if (l.RW_PW == "PW") { l.Koszt_IPO = Math.Round((double)tkw * (double)l.Ilosc, 3); } if (l.RW_PW == "RW") { l.Koszt_IPO = Math.Round((double)tkw * (double)-l.Ilosc, 3); } if (l.RW_PW == "PU") { l.Koszt_IPO = Math.Round((double)tkw * (double)-l.Ilosc, 3); } db.SubmitChanges(); } var total = (from c in linie where c.RW_PW == "RW" select new { TYP = "JDE", c.Nr_zlecenia_IPO, Indeks = c.Nr_indeksu.Trim(), c.Nazwa_pozycji, c.Ilosc, c.Koszt_IPO }) .Concat(from g in linie_norma select new { TYP = "NORMA", g.Nr_zlecenia_IPO, Indeks = g.Nr_indeksu.Trim(), g.Nazwa_pozycji, g.Ilosc, g.Koszt_IPO }).ToArray(); // zgrupuj List <Item> lst = new List <Item>(); //utwórz listę indeksów var lista_indeksow = (from c in total select c.Indeks).Distinct(); foreach (var i in lista_indeksow) { Item itm = new Item(); var tmp = from c in total where c.Indeks == i select c; itm.Nr_indeksu = i; itm.Nazwa = tmp.First().Nazwa_pozycji; itm.Ilość_JDE = (double)(from c in tmp where c.TYP == "JDE" select c.Ilosc).Sum(); itm.Wartość_JDE = (double)(from c in tmp where c.TYP == "JDE" select c.Koszt_IPO).Sum(); itm.Ilość_NORMA = (double)(from c in tmp where c.TYP == "NORMA" select c.Ilosc).Sum(); itm.Wartość_NORMA = (double)(from c in tmp where c.TYP == "NORMA" select c.Koszt_IPO).Sum(); itm.Różnica_ilość = Math.Round(itm.Ilość_JDE + itm.Ilość_NORMA); itm.Różnica_wartość = Math.Round(itm.Wartość_JDE + itm.Wartość_NORMA, 3); lst.Add(itm); } dataGridView1.DataSource = lst; dataGridView1.Update(); }
public static void GenKKC(int nr_zlec, string id_prac, string oper, string id_masz) { db_raportyDataContext db = new db_raportyDataContext(); string ARIALUNI_TFF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF"); //Create a base font object making sure to specify IDENTITY-H BaseFont bf = BaseFont.CreateFont(ARIALUNI_TFF, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //Create a specific font object iTextSharp.text.Font f = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.NORMAL); iTextSharp.text.Font fb = new iTextSharp.text.Font(bf, 13, iTextSharp.text.Font.NORMAL); iTextSharp.text.Font fn = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL); iTextSharp.text.Font fvb = new iTextSharp.text.Font(bf, 16, iTextSharp.text.Font.BOLDITALIC); WebReference.Service1 client = new WebReference.Service1(); DB2008DataContext dbx = new DB2008DataContext(); string file_path = System.IO.Path.GetTempPath() + "_" + nr_zlec + "_" + DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("HHmmssfff") + ".pdf"; FileStream fs = new FileStream(file_path, FileMode.OpenOrCreate, FileAccess.ReadWrite); Document document = new Document(PageSize.A4, 10f, 10f, 10f, 20f); PdfWriter writer = PdfWriter.GetInstance(document, fs); WebReference.IPO_Order ord = client.IPO_GET_ORDER(nr_zlec); WebReference.Item itm = client.IPO_GET_ITEM_BY_ITM(int.Parse(ord.item_id)); document.Open(); document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); document.NewPage(); Paragraph nri = new Paragraph("39WF01 rev. 27.10.2016", f); nri.Alignment = 2; document.Add(nri); nri = new Paragraph("KKC - KARTA KONTROLI CYKLU DO ZLECENIA IPO NR: " + nr_zlec.ToString(), fb); nri.Alignment = 1; document.Add(nri); document.Add(new Paragraph("NAZWA: " + itm.name, fb)); document.Add(new Paragraph("INDEKS: " + itm.index, fb)); document.Add(new Paragraph("OPERACJA: " + oper, fvb)); document.Add(new Paragraph("NR MASZYNY: " + id_masz, fvb)); var marsz = from c in dbx.IPO_Marszruties orderby c.Typ, c.Nr_oper where c.Indeks == itm.index && c.Typ == "M" select c; string co_ile = ""; co_ile = "Kontrolować zgodnie z instrukcją 39W."; document.Add(new Paragraph(" ", f)); document.Add(new Paragraph("Wymiary kontrolne. " + co_ile, fb)); document.Add(new Paragraph(" ", f)); var kart = (from c in marsz.Where(x => x.Nr_Karty != "") select new { KARTA = c.Nr_Karty }).Distinct(); PdfPTable kkc = new PdfPTable(23); float[] widths = new float[] { 10f, 25f, 45f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f }; kkc.SetWidths(widths); PdfPCell cell; cell = new PdfPCell(new Phrase("Nr", f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase("Nr_karty", f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase("Wymiar kontr.", f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase("Pierw, szt 1-...", f)); kkc.AddCell(cell); for (int t = 1; t < 20; t++) { cell = new PdfPCell(new Phrase("Spr" + t.ToString(), f)); kkc.AddCell(cell); } if (kart.Count() > 0) { var cykl = from g in kart join k in dbx.F00192s.Where(x => x.CFSY == "48" && x.CFRT == "SN") on g.KARTA equals k.CFKY select new { g.KARTA, NR = k.CFLINS / 100, k.CFDS80 }; foreach (var c in cykl) { cell = new PdfPCell(new Phrase(c.NR.ToString(), f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase(c.KARTA, f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase(c.CFDS80, f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase(". . . ", f)); kkc.AddCell(cell); for (int t = 1; t < 20; t++) { cell = new PdfPCell(new Phrase(" ", f)); kkc.AddCell(cell); } } document.Add(kkc); document.Add(new Paragraph(" ", f)); document.Add(new Paragraph("Utworzono: " + DateTime.Now.ToString(), f)); document.Add(new Paragraph("ZALECENIA I UWAGI USTAWIACZA: ", f)); document.Close(); writer.Close(); SendToPrinter(file_path); //Process.Start(file_path); } }
public static void Gen_przew(List <int> tab_nr_zlec, string user_name, bool KKC) { db_raportyDataContext db = new db_raportyDataContext(); string ARIALUNI_TFF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF"); //Create a base font object making sure to specify IDENTITY-H BaseFont bf = BaseFont.CreateFont(ARIALUNI_TFF, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //Create a specific font object iTextSharp.text.Font f = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.NORMAL); iTextSharp.text.Font fb = new iTextSharp.text.Font(bf, 13, iTextSharp.text.Font.NORMAL); iTextSharp.text.Font fn = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL); WebReference.Service1 client = new WebReference.Service1(); DB2008DataContext dbx = new DB2008DataContext(); string file_path = System.IO.Path.GetTempPath() + user_name + "_" + DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("HHmmssfff") + ".pdf"; FileStream fs = new FileStream(file_path, FileMode.OpenOrCreate, FileAccess.ReadWrite); Document document = new Document(PageSize.A4, 10f, 10f, 10f, 20f); PdfWriter writer = PdfWriter.GetInstance(document, fs); document.Open(); document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); foreach (int nr_zlec in tab_nr_zlec) { document.NewPage(); // PdfContentByte cb = writer.DirectContent; // cb.Rectangle(20f, 20f, 100f, 200f); // cb.Stroke(); // var zl1 = (from c in db.IPO_ZLECENIAs // where c.ipo_nr_zlec == nr_zlec // select c).Single(); WebReference.IPO_Order ord = client.IPO_GET_ORDER(nr_zlec); WebReference.Item itm = client.IPO_GET_ITEM_BY_ITM(int.Parse(ord.item_id)); Paragraph p = new Paragraph("PRZEWODNIK DO ZLECENIA IPO NR: " + nr_zlec.ToString(), fb); p.Alignment = 1; document.Add(p); document.Add(new Paragraph(" ", f)); p = new Paragraph(itm.index + " " + itm.name, fb); p.Alignment = 1; document.Add(p); document.Add(new Paragraph(" ", f)); PdfPTable table = new PdfPTable(6); float[] widths = new float[] { 15f, 50f, 15f, 25f, 25f, 25f }; table.SetWidths(widths); PdfPCell cell = new PdfPCell(new Phrase("Indeks", f)); table.AddCell(cell); cell = new PdfPCell(new Phrase("Nazwa", f)); table.AddCell(cell); cell = new PdfPCell(new Phrase("Seria", f)); table.AddCell(cell); cell = new PdfPCell(new Phrase("PLAN IPO", f)); table.AddCell(cell); cell = new PdfPCell(new Phrase("KKC", f)); table.AddCell(cell); cell = new PdfPCell(new Phrase("Wystawił:", f)); table.AddCell(cell); //table.AddCell(); cell = new PdfPCell(new Phrase(itm.index, f)); table.AddCell(cell); //table.AddCell(itm.name); cell = new PdfPCell(new Phrase(itm.name, f)); table.AddCell(cell); //table.AddCell(zl.ilosc_zam.ToString()); cell = new PdfPCell(new Phrase(ord.quantity.ToString(), f)); table.AddCell(cell); //table.AddCell(zl.stop_zam.Value.ToShortDateString()); cell = new PdfPCell(new Phrase(ord.order_no_cust, f)); table.AddCell(cell); //table.AddCell("???"); cell = new PdfPCell(new Phrase(" ", f)); table.AddCell(cell); //table.AddCell(user_name); cell = new PdfPCell(new Phrase(user_name + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), f)); table.AddCell(cell); document.Add(table); document.Add(new Paragraph(" ", f)); document.Add(new Paragraph("LISTA MATERIAŁÓW DO POBRANIA: ", fn)); document.Add(new Paragraph(" ", f)); List <WebReference.IPO_BOM_Line> bom = client.IPO_BOM_ITEM(itm.index).ToList <WebReference.IPO_BOM_Line>(); PdfPTable tbom = new PdfPTable(14); widths = new float[] { 15f, 50f, 15f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f }; tbom.SetWidths(widths); cell = new PdfPCell(new Phrase("Indeks", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("Nazwa", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("Do pobrania", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("Pobrano na RW", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("Wykorzystano", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("BRAK-1", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("BRAK-2", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("BRAK-3", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("BRAK-4", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("BRAK-5", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("BRAK-6", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("BRAK-7", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("BRAK-8", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase("JW", f)); tbom.AddCell(cell); foreach (WebReference.IPO_BOM_Line b in bom) { WebReference.Item bitm = client.IPO_GET_ITEM_BY_ITM(b.item_id); cell = new PdfPCell(new Phrase(bitm.index, f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(bitm.name, f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase((Convert.ToDouble(b.quantity) * (double)ord.quantity).ToString("###.00"), f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(". . . . ", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(" ", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(" ", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(" ", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(" ", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(" ", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(" ", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(" ", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(" ", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(" ", f)); tbom.AddCell(cell); cell = new PdfPCell(new Phrase(" ", f)); tbom.AddCell(cell); } document.Add(tbom); document.Add(new Paragraph(" ", f)); document.Add(new Paragraph("Informacja o marszrucie: ", fn)); document.Add(new Paragraph(" ", f)); PdfPTable mtab = new PdfPTable(5); widths = new float[] { 10f, 15f, 50f, 35f, 15f }; mtab.SetWidths(widths); cell = new PdfPCell(new Phrase("Nr operacji", f)); mtab.AddCell(cell); cell = new PdfPCell(new Phrase("Grupa operacji", f)); mtab.AddCell(cell); cell = new PdfPCell(new Phrase("Opis", f)); mtab.AddCell(cell); cell = new PdfPCell(new Phrase("Operacja", f)); mtab.AddCell(cell); cell = new PdfPCell(new Phrase("Nr_karty", f)); mtab.AddCell(cell); var marsz = from c in dbx.IPO_Marszruties orderby c.Typ, c.Nr_oper where c.Indeks == itm.index && c.Typ == "M" select c; foreach (var l in marsz) { cell = new PdfPCell(new Phrase(l.Nr_oper.ToString(), f)); mtab.AddCell(cell); cell = new PdfPCell(new Phrase(l.Grupa_oper, f)); mtab.AddCell(cell); cell = new PdfPCell(new Phrase(l.Opis, f)); mtab.AddCell(cell); cell = new PdfPCell(new Phrase(l.Operacja, f)); mtab.AddCell(cell); cell = new PdfPCell(new Phrase(l.Nr_Karty, f)); mtab.AddCell(cell); } document.Add(mtab); var kart = (from c in marsz.Where(x => x.Nr_Karty != "") select new { KARTA = c.Nr_Karty }).Distinct(); if (kart.Count() > 0) { var cykl = from g in kart join k in dbx.F00192s.Where(x => x.CFSY == "48" && x.CFRT == "SN") on g.KARTA equals k.CFKY select new { g.KARTA, NR = k.CFLINS / 100, k.CFDS80 }; PdfPTable kkc = new PdfPTable(23); widths = new float[] { 10f, 25f, 45f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f, 14f }; kkc.SetWidths(widths); cell = new PdfPCell(new Phrase("Nr", f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase("Nr_karty", f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase("Wymiar kontr.", f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase("Pierw, szt 1-...", f)); kkc.AddCell(cell); for (int t = 1; t < 20; t++) { cell = new PdfPCell(new Phrase("Spr" + t.ToString(), f)); kkc.AddCell(cell); } foreach (var c in cykl) { cell = new PdfPCell(new Phrase(c.NR.ToString(), f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase(c.KARTA, f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase(c.CFDS80, f)); kkc.AddCell(cell); cell = new PdfPCell(new Phrase(". . . ", f)); kkc.AddCell(cell); for (int t = 1; t < 20; t++) { cell = new PdfPCell(new Phrase(" ", f)); kkc.AddCell(cell); } } if (KKC) { if (cykl.Count() > 0) { document.NewPage(); document.Add(new Paragraph("KKC - KARTA KONTROLI CYKLU DO ZLECENIA IPO NR: " + nr_zlec.ToString(), fb)); document.Add(new Paragraph(" ", f)); document.Add(table); document.Add(new Paragraph(" ", f)); document.Add(new Paragraph("Informacja o marszrucie: ", fn)); document.Add(new Paragraph(" ", f)); document.Add(mtab); string co_ile = ""; if (ord.quantity < 10) { co_ile = "Kontrolować wszystkie szt."; } if (ord.quantity >= 10) { co_ile = "Kontrolować co 10 szt."; } if (ord.quantity >= 50) { co_ile = "Kontrolować co 20 szt."; } if (ord.quantity >= 101) { co_ile = "Kontrolować co 50 szt."; } if (ord.quantity >= 1001) { co_ile = "Kontrolować co 150 szt."; } if (ord.quantity >= 3001) { co_ile = "Kontrolować co 300 szt."; } document.Add(new Paragraph(" ", f)); document.Add(new Paragraph("Wymiary kontrolne. " + co_ile, fb)); document.Add(new Paragraph(" ", f)); document.Add(kkc); } } } } document.Close(); writer.Close(); Process.Start(file_path); }
private void button2_Click(object sender, EventArgs e) { //waliduj dane double check; if (!string.IsNullOrEmpty(tb_ilosc.Text)) { if (!Double.TryParse(tb_ilosc.Text, out check)) { MessageBox.Show("POPRAW ILOŚĆ!!!"); return; } } if (!string.IsNullOrEmpty(tb_ilosc_brak.Text)) { if (!Double.TryParse(tb_ilosc_brak.Text, out check)) { MessageBox.Show("POPRAW ILOŚĆ_BRAK!!!"); return; } } string nstartc; nstartc = dtp_data_start.Value.ToString("yyyy-MM-dd") + " " + dtp_czas_start.Value.ToLongTimeString(); string nstopc; nstopc = dtp_data_stop.Value.ToString("yyyy-MM-dd") + " " + dtp_czas_stop.Value.ToLongTimeString(); if (DateTime.Parse(nstopc) < DateTime.Parse(nstartc)) { MessageBox.Show("CZAS STOP WIĘKSZY OD START - POPRAW!!!"); return; } db_raportyDataContext db = new db_raportyDataContext(); if (!string.IsNullOrEmpty(tbIndeks.Text)) { DB2008DataContext db1 = new DB2008DataContext(); var itm = from c in db1.SLOWNIK_1s where c.IMLITM == tbIndeks.Text select c; if (itm.Count() != 1) { MessageBox.Show("Podaj poprawny indeks!!!"); return; } var _itm = itm.First(); var to_delete1 = from c in db.IPO_Tasks_korektas where c.Task_id == task_id && c.Typ_korekty == "INDEKS_ITM" select c; db.IPO_Tasks_korektas.DeleteAllOnSubmit(to_delete1); db.SubmitChanges(); IPO_Tasks_korekta kor1 = new IPO_Tasks_korekta(); kor1.Typ_korekty = "INDEKS_ITM"; kor1.Task_id = task_id; kor1.Dane = _itm.IMITM.ToString(); kor1.Utworzony_przez = login; kor1.Utworzony = DateTime.Now; db.IPO_Tasks_korektas.InsertOnSubmit(kor1); db.SubmitChanges(); var to_delete = from c in db.IPO_Tasks_korektas where c.Task_id == task_id && c.Typ_korekty == "INDEKS" select c; db.IPO_Tasks_korektas.DeleteAllOnSubmit(to_delete); db.SubmitChanges(); IPO_Tasks_korekta kor = new IPO_Tasks_korekta(); kor.Typ_korekty = "INDEKS"; kor.Task_id = task_id; kor.Dane = tbIndeks.Text; kor.Utworzony_przez = login; kor.Utworzony = DateTime.Now; db.IPO_Tasks_korektas.InsertOnSubmit(kor); db.SubmitChanges(); db.UpdateJDE(task_id); } //najpierw usuń stare zapisy if (!string.IsNullOrEmpty(tb_ilosc.Text)) { var to_delete = from c in db.IPO_Tasks_korektas where c.Task_id == task_id && c.Typ_korekty == "ILOSC" select c; db.IPO_Tasks_korektas.DeleteAllOnSubmit(to_delete); db.SubmitChanges(); IPO_Tasks_korekta kor = new IPO_Tasks_korekta(); kor.Typ_korekty = "ILOSC"; kor.Task_id = task_id; kor.Dane = tb_ilosc.Text; kor.Utworzony_przez = login; kor.Utworzony = DateTime.Now; db.IPO_Tasks_korektas.InsertOnSubmit(kor); db.SubmitChanges(); db.UpdateJDE(task_id); } if (!string.IsNullOrEmpty(tb_ilosc_brak.Text)) { var to_delete = from c in db.IPO_Tasks_korektas where c.Task_id == task_id && c.Typ_korekty == "ILOSC_BRAK" select c; db.IPO_Tasks_korektas.DeleteAllOnSubmit(to_delete); db.SubmitChanges(); IPO_Tasks_korekta kor = new IPO_Tasks_korekta(); kor.Typ_korekty = "ILOSC_BRAK"; kor.Task_id = task_id; kor.Dane = tb_ilosc_brak.Text; kor.Utworzony_przez = login; kor.Utworzony = DateTime.Now; db.IPO_Tasks_korektas.InsertOnSubmit(kor); db.SubmitChanges(); db.UpdateJDE(task_id); } if (!string.IsNullOrEmpty(tb_nazwa_operacji.Text)) { var to_delete = from c in db.IPO_Tasks_korektas where c.Task_id == task_id && c.Typ_korekty == "NAZWA_OPERACJI" select c; db.IPO_Tasks_korektas.DeleteAllOnSubmit(to_delete); db.SubmitChanges(); IPO_Tasks_korekta kor = new IPO_Tasks_korekta(); kor.Typ_korekty = "NAZWA_OPERACJI"; kor.Task_id = task_id; kor.Dane = tb_nazwa_operacji.Text; kor.Utworzony_przez = login; kor.Utworzony = DateTime.Now; db.IPO_Tasks_korektas.InsertOnSubmit(kor); db.SubmitChanges(); db.UpdateJDE(task_id); } if (!string.IsNullOrEmpty(tb_opis_pracy.Text)) { var to_delete = from c in db.IPO_Tasks_korektas where c.Task_id == task_id && c.Typ_korekty == "OPIS_PRACY" select c; db.IPO_Tasks_korektas.DeleteAllOnSubmit(to_delete); db.SubmitChanges(); IPO_Tasks_korekta kor = new IPO_Tasks_korekta(); kor.Typ_korekty = "OPIS_PRACY"; kor.Task_id = task_id; kor.Dane = tb_opis_pracy.Text; kor.Utworzony_przez = login; kor.Utworzony = DateTime.Now; db.IPO_Tasks_korektas.InsertOnSubmit(kor); db.SubmitChanges(); db.UpdateJDE(task_id); } if (dtp_data_start.Checked) { string nstart; nstart = dtp_data_start.Value.ToShortDateString() + " " + dtp_czas_start.Value.ToLongTimeString(); var to_delete = from c in db.IPO_Tasks_korektas where c.Task_id == task_id && c.Typ_korekty == "START" select c; db.IPO_Tasks_korektas.DeleteAllOnSubmit(to_delete); db.SubmitChanges(); IPO_Tasks_korekta kor = new IPO_Tasks_korekta(); kor.Typ_korekty = "START"; kor.Task_id = task_id; kor.Dane = nstart; kor.Utworzony_przez = login; kor.Utworzony = DateTime.Now; db.IPO_Tasks_korektas.InsertOnSubmit(kor); db.SubmitChanges(); db.UpdateJDE(task_id); } if (dtp_data_stop.Checked) { string nstop; nstop = dtp_data_stop.Value.ToShortDateString() + " " + dtp_czas_stop.Value.ToLongTimeString(); var to_delete = from c in db.IPO_Tasks_korektas where c.Task_id == task_id && c.Typ_korekty == "STOP" select c; db.IPO_Tasks_korektas.DeleteAllOnSubmit(to_delete); db.SubmitChanges(); IPO_Tasks_korekta kor = new IPO_Tasks_korekta(); kor.Typ_korekty = "STOP"; kor.Task_id = task_id; kor.Dane = nstop; kor.Utworzony_przez = login; kor.Utworzony = DateTime.Now; db.IPO_Tasks_korektas.InsertOnSubmit(kor); db.SubmitChanges(); db.UpdateJDE(task_id); } this.Close(); }
public static List <Item> Lista_pozycji(int nr_zlec) { var srv = new WebReference.Service1(); List <Item> lst = new List <Item>(); var db = new db_raportyDataContext(); var db2008 = new DB2008DataContext(); //skasuj stare rozpisy var do_skas = from c in db.IPO_ZDAWKA_PW_NORMAs where c.Nr_zlecenia_IPO == nr_zlec select c; db.IPO_ZDAWKA_PW_NORMAs.DeleteAllOnSubmit(do_skas); db.SubmitChanges(); var linie = from c in db.IPO_ZDAWKA_PWs where c.Nr_zlecenia_IPO == nr_zlec select c; double ilosc_zlec = (double)(from c in linie where c.RW_PW == "PW" select c.Ilosc).Sum(); srv.Dodaj_rozpis_do_Tabeli(nr_zlec, 0, ilosc_zlec); var linie_norma = from c in db.IPO_ZDAWKA_PW_NORMAs where c.Nr_zlecenia_IPO == nr_zlec && c.RW_PW == "RW" select c; //wycen normę foreach (var l in linie_norma) { var tkw = (from c in db.słownik_TKWs where c.Indeks.Trim() == l.Nr_indeksu.Trim() select c.Koszt).FirstOrDefault(); if (l.RW_PW == "PW") { l.Koszt_IPO = Math.Round((double)tkw * (double)l.Ilosc, 3); } if (l.RW_PW == "RW") { l.Koszt_IPO = Math.Round((double)tkw * (double)-l.Ilosc, 3); } if (l.RW_PW == "PU") { l.Koszt_IPO = Math.Round((double)tkw * (double)-l.Ilosc, 3); } db.SubmitChanges(); } //wyceń materiały - nie przejmujemy się jednostkami. foreach (var l in linie) { var tkw = (from c in db.słownik_TKWs where c.Indeks.Trim() == l.Nr_indeksu.Trim() select c.Koszt).FirstOrDefault(); if (l.RW_PW == "PW") { l.Koszt_IPO = Math.Round((double)tkw * (double)l.Ilosc, 3); } if (l.RW_PW == "RW") { l.Koszt_IPO = Math.Round((double)tkw * (double)-l.Ilosc, 3); } if (l.RW_PW == "PU") { l.Koszt_IPO = Math.Round((double)tkw * (double)-l.Ilosc, 3); } db.SubmitChanges(); } var total = (from c in linie where c.RW_PW == "RW" select new { TYP = "JDE", c.Nr_zlecenia_IPO, Indeks = c.Nr_indeksu.Trim(), c.Nazwa_pozycji, c.Ilosc, c.Koszt_IPO }) .Concat(from g in linie_norma select new { TYP = "NORMA", g.Nr_zlecenia_IPO, Indeks = g.Nr_indeksu.Trim(), g.Nazwa_pozycji, g.Ilosc, g.Koszt_IPO }).ToArray(); // zgrupuj //utwórz listę indeksów var lista_indeksow = (from c in total select c.Indeks).Distinct(); foreach (var i in lista_indeksow) { Item itm = new Item(); var tmp = from c in total where c.Indeks == i select c; itm.Nr_zlecenia = nr_zlec; itm.Indeks_wyrobu_zl = linie.Where(c => c.RW_PW == "PW").First().Nazwa_pozycji; itm.Nr_indeksu = i; itm.Nazwa = tmp.First().Nazwa_pozycji; itm.Ilość_JDE = (double)(from c in tmp where c.TYP == "JDE" select c.Ilosc).Sum(); itm.Wartość_JDE = (double)(from c in tmp where c.TYP == "JDE" select c.Koszt_IPO).Sum(); itm.Ilość_NORMA = (double)(from c in tmp where c.TYP == "NORMA" select c.Ilosc).Sum(); itm.Wartość_NORMA = (double)(from c in tmp where c.TYP == "NORMA" select c.Koszt_IPO).Sum(); itm.Różnica_ilość = Math.Round(itm.Ilość_JDE + itm.Ilość_NORMA); itm.Różnica_wartość = Math.Round(itm.Wartość_JDE + itm.Wartość_NORMA, 3); lst.Add(itm); } return(lst); }