public void TambahBarang(Barang pBarang)
        {
            Barang b = new Barang(pBarang.Kode, pBarang.Nama, pBarang.Jumlah, pBarang.Satuan, pBarang.HargaSatuan, pBarang.Keterangan, this);

            this.ListBarang.Add(b);
        }
Exemplo n.º 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);
            }
        }