Пример #1
0
        public static string BacaData(string kriteria, string kriteria2, string nilaiKriteria, string nilaikriteria2, List <BOM> listHasilData)
        {
            string sql = "";

            // JIka tidak ada kriteria yang diisikan

            sql = "SELECT * FROM bill_of_materials WHERE " + kriteria + " LIKE '%" + nilaiKriteria + "%' AND " + kriteria2 + " LIKE '%" + nilaikriteria2 + "%'";


            try
            {
                MySqlDataReader hasilData = Koneksi.JalankanPerintahQuery(sql);

                while (hasilData.Read() == true) // selama masih ada data atau selama masih bisa membaca data
                {
                    // Baca hasil dari MySqlDataReader dan simpan di objek
                    BOM b = new BOM();
                    b.IdbahanBaku            = hasilData.GetValue(0).ToString();
                    b.Kodebarang             = hasilData.GetValue(1).ToString();
                    b.JumlahBagian           = hasilData.GetValue(2).ToString();
                    b.JumlahBijiLembarBatang = hasilData.GetValue(3).ToString();
                    b.TotalBiaya             = int.Parse(hasilData.GetValue(4).ToString());
                    b.BiayaOperasional       = int.Parse(hasilData.GetValue(5).ToString());
                    b.BiayaTukang            = int.Parse(hasilData.GetValue(6).ToString());
                    b.PengajuanHarga         = int.Parse(hasilData.GetValue(7).ToString());

                    // Simpan ke list
                    listHasilData.Add(b);
                }

                return("1");
            }
            catch (MySqlException exc)
            {
                return(exc.Message + ". Perintah sql : " + sql);
            }
        }
Пример #2
0
        public static string PrintBOM(string kriteria, string nilaiKriteria, string filename)
        {
            try
            {
                List <BOM>       lb     = new List <BOM>();
                List <Barang>    brg    = new List <Barang>();
                List <BahanBaku> bb     = new List <BahanBaku>();
                string           hasil  = BOM.BacaData(kriteria, nilaiKriteria, lb);
                string           barang = Barang.BacaData("kode", lb[0].Kodebarang, brg);

                StreamWriter file              = new StreamWriter(filename);
                int          totalbiayabom     = 0;
                int          totalpengajuanbom = 0;
                file.WriteLine("");
                file.WriteLine("TEACHING INDUSTRY");
                file.WriteLine("Jl. Tenggilis Mejoyo, Kali Rungkut, Rungkut, Surabaya.");
                file.WriteLine("+62 812-9536-9977");
                file.WriteLine("=".PadRight(50, '='));
                file.WriteLine("DOKUMEN BILL OF MATERIALS");
                file.WriteLine("Kode Barang : " + brg[0].Kode);
                file.WriteLine("Nama Barang : " + brg[0].Nama);
                file.WriteLine("Keterangan : " + brg[0].Keterangan);
                file.WriteLine("=".PadRight(50, '='));
                for (int i = 0; i < lb.Count; i++)
                {
                    string pnamaBahan        = "";
                    string pbagian           = "";
                    string pUkuranMentah     = "";
                    string pUkuranJadi       = "";
                    string pUkuranLuas       = "";
                    string pjumlahbagian     = lb[i].JumlahBagian;
                    string pjumlahspes       = lb[i].JumlahBijiLembarBatang;
                    string ptotalbiaya       = lb[i].TotalBiaya.ToString("0,###");
                    string pbiayaoperasional = lb[i].BiayaOperasional.ToString("0,###");
                    string ppengajuanHarga   = lb[i].PengajuanHarga.ToString("0,###");
                    string bk = BahanBaku.BacaData("BB.id", lb[i].IdbahanBaku, bb);
                    for (int j = 0; j < bb.Count; j++)
                    {
                        if (bb[j].Id == lb[i].IdbahanBaku)
                        {
                            pnamaBahan    = bb[j].Nama;
                            pUkuranJadi   = bb[j].UkuranJadi;
                            pbagian       = bb[j].Bagian;
                            pUkuranLuas   = bb[j].UkuranLuasan;
                            pUkuranMentah = bb[j].UkuranMentah;
                        }
                    }
                    if (pnamaBahan.Length > 25)
                    {
                        pnamaBahan = pnamaBahan.Substring(0, 25);
                    }
                    totalbiayabom     += lb[i].TotalBiaya;
                    totalpengajuanbom += lb[i].PengajuanHarga;
                    file.Write(pnamaBahan.PadRight(25, ' '));
                    file.Write(pbagian.PadRight(19, ' '));
                    file.Write(pUkuranMentah.PadRight(14, ' '));
                    file.Write(pUkuranJadi.PadRight(14, ' '));
                    file.Write(pUkuranLuas.PadRight(14, ' '));
                    file.Write(pjumlahbagian.PadRight(5, ' '));
                    file.Write(pjumlahspes.PadRight(5, ' '));
                    file.Write(ptotalbiaya.PadLeft(15, ' '));
                    file.Write(pbiayaoperasional.PadLeft(15, ' '));
                    file.Write(ppengajuanHarga.PadLeft(15, ' '));
                    file.WriteLine("");
                }
                file.WriteLine("=".PadRight(50, '='));
                file.WriteLine("TOTAL BIAYA : " + totalbiayabom.ToString());
                file.WriteLine("TOTAL PENGAJUAN HARGA : " + totalpengajuanbom.ToString());
                file.WriteLine("=".PadRight(50, '='));
                file.Close();
                Print p = new Print(filename);
                p.PrinttoPrinter("text");
                return("1");
            }
            catch (MySqlException e) {
                return(e.Message);
            }
        }