private void btnBuatBayar_Click(object sender, EventArgs e)
        {
            int sisaBayar = totalHargaAsli - totalBayar;

            sisaBayar = sisaBayar < 0 ? 0 : sisaBayar;

            int sisaBayarPalsu = totalHargaNota - totalBayarPalsu;

            sisaBayarPalsu = sisaBayarPalsu < 0 ? 0 : sisaBayarPalsu;
            CreateSalesPayment createSalesPayment = new CreateSalesPayment(main, salesID, sisaBayar, sisaBayarPalsu);
            DialogResult       result             = createSalesPayment.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                RefreshPayment(salesID);
            }
        }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            employeeID = main.globalEmployeeID;

            if (cart.Count == 0)
            {
                main.SetMessage("Isi keranjang belanjaan dulu");
            }
            else if (employeeID == 0)
            {
                main.SetMessage("Belom pilih karyawan");
            }
            else if (customerID == 0)
            {
                main.SetMessage("Belom pilih customer");
            }
            else
            {
                //KALO SUDAH DI ISI SEMUA
                if (tbNoJob.Text == "")
                {
                    string status = "SALE";
                    if (rbPenawaran.Checked)
                    {
                        status = "OFFER";
                    }


                    //INSERT DATA TRANSACTION
                    // 1 > HEADER
                    ExecuteQuery("INSERT INTO PrintingSalesHeader(customerID, salesTime, purchaseOrderID, deliveryNote, tempo, status) VALUES ('" + customerID +
                                 "', now(), '" + noPO + "', '" + tbAlamatAntar.Text + "; U/p. " + tbPenerima.Text + "', '" +
                                 (ckbTempo.Checked ? dtpTempo.Value.ToString("yyyy-MM-dd") : "1900-01-01") + "', '" + status + "')");
                    DataTable dt = ExecuteQuery("SELECT printingSalesID FROM PrintingSalesHeader ORDER BY printingSalesID DESC LIMIT 0, 1"); // ambil id terakhir
                    if (dt != null)
                    {
                        if (dt.Rows.Count == 1)
                        {
                            tbNoJob.Text = String.Format("{0:D6}", Int32.Parse(dt.Rows[0]["printingSalesID"].ToString()));
                        }

                        //harus di dalam soalnya kalo ga kecari ga boleh di execute
                        // 2 > DETAIL
                        foreach (PrintingCreateSalesList i in cart)
                        {
                            int    printApproval = 0;
                            string printApprovalImage = "", printApprovalSigner = "";
                            string deadline = "";

                            if (i.deadline > dtpSalesTime.Value.AddHours(1))
                            {
                                deadline = i.deadline.ToString("yyyy-MM-dd HH:mm:ss");
                            }
                            else
                            {
                                deadline = "1900-01-01 00:00:00";
                            }

                            if (i.jobType == "ST")
                            {
                                int timerID = Int32.Parse(i.paperSize.Substring(i.paperSize.LastIndexOf(" ")));
                                ExecuteQuery("UPDATE PrintingTimerHeader SET status = 1 WHERE printingTimerID = '" + timerID + "'");
                            }

                            ExecuteQuery("INSERT INTO PrintingSalesDetail(printingSalesID, printingType, printingTitle, jobType, previewFile, quantity, " +
                                         "quantityType, inschiet, inschietType, material, paperSize, imageSize, sidePrint, totalPlat, description, note, " +
                                         "hargaAsli, hargaMaterial, hargaOngkosCetak, deadline, printApproval, printApprovalImage, " +
                                         "printApprovalSigner, status, digitalCounter, offsetCounter) " +
                                         "VALUES " +
                                         "('" + tbNoJob.Text + "', '" + i.printingType + "', '" + i.printingTitle + "', '" + i.jobType + "', '" + i.previewFile +
                                         "', '" + i.quantity + "', '" + i.quantityType + "', '" + i.inschiet + "', '" + i.inschietType +
                                         "', '" + i.material + "', '" + i.paperSize + "', '" + i.imageSize + "', '" + i.sidePrint +
                                         "', '" + i.totalPlat + "', '" + i.description + "', '" + i.note + "', '" + i.hargaAsli +
                                         "', '" + i.hargaMaterial + "', '" + i.hargaOngkosCetak + "', '" + deadline +
                                         "', '" + printApproval + "', '" + printApprovalImage + "', '" + printApprovalSigner + "', 'none', '" + i.digitalCounter + "', '" + i.offsetCounter + "')");

                            if (i.finishing != null)
                            {
                                foreach (string[] j in i.finishing)
                                {
                                    ExecuteQuery("INSERT INTO PrintingSalesDetailFinishing(printingSalesID, printingType, printingTitle, finishingType, detail, note, process) " +
                                                 "VALUES " +
                                                 "('" + tbNoJob.Text + "', '" + i.printingType + "', '" + i.printingTitle + "', '" + j[0] + "', '" + j[1] + "', '" + j[2] + "', '0')");
                                }
                            }
                        }
                    }

                    int hargaAsli  = Convert.ToInt32(nudTotalBelanja.Value);
                    int hargaPalsu = Convert.ToInt32(nudTotalNota.Value);
                    CreateSalesPayment salesPayment = new CreateSalesPayment(main, Int32.Parse(tbNoJob.Text), hargaAsli, hargaPalsu);
                    DialogResult       result       = salesPayment.ShowDialog();
                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        main.SetMessage("Pembayaran sudah dimasukkan..");
                        closeWindow();
                    }
                    main.ShowSalesPrintingRefresh();
                }
                else
                {
                    string tempoTemp;
                    //UPDATE DATA TRANSACTION
                    if (ckbTempo.Checked == true)
                    {
                        tempoTemp = dtpTempo.Value.ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        tempoTemp = "1900-01-01";
                    }

                    ExecuteQuery("UPDATE PrintingSalesHeader SET customerID = '" + customerID + (dtpSalesTime.Checked == true ? "', salesTime = '" + dtpSalesTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + "', purchaseOrderID = '" + noPO + "', deliveryNote = '" + tbAlamatAntar.Text + "; U/p. " + tbPenerima.Text + "', tempo = '" + tempoTemp + "' WHERE printingSalesID = '" + Int32.Parse(tbNoJob.Text) + "'");

                    ExecuteQuery("DELETE FROM PrintingSalesDetail WHERE printingSalesID = '" + tbNoJob.Text + "'");
                    ExecuteQuery("DELETE FROM PrintingSalesDetailFinishing WHERE printingSalesID = '" + tbNoJob.Text + "'");

                    foreach (PrintingCreateSalesList i in cart)
                    {
                        int    printApproval = 0;
                        string printApprovalImage = "", printApprovalSigner = "";
                        string deadline = "";

                        if (i.deadline > dtpSalesTime.Value.AddHours(1))
                        {
                            deadline = i.deadline.ToString("yyyy-MM-dd HH:mm:ss");
                        }
                        else
                        {
                            deadline = "1900-01-01 00:00:00";
                        }

                        ExecuteQuery("INSERT INTO PrintingSalesDetail(printingSalesID, printingType, printingTitle, jobType, previewFile, quantity, " +
                                     "quantityType, inschiet, inschietType, material, paperSize, imageSize, sidePrint, totalPlat, description, note, " +
                                     "hargaAsli, hargaMaterial, hargaOngkosCetak, deadline, printApproval, printApprovalImage, " +
                                     "printApprovalSigner, status, digitalCounter, offsetCounter) " +
                                     "VALUES " +
                                     "('" + tbNoJob.Text + "', '" + i.printingType + "', '" + i.printingTitle + "', '" + i.jobType + "', '" + i.previewFile +
                                     "', '" + i.quantity + "', '" + i.quantityType + "', '" + i.inschiet + "', '" + i.inschietType +
                                     "', '" + i.material + "', '" + i.paperSize + "', '" + i.imageSize + "', '" + i.sidePrint +
                                     "', '" + i.totalPlat + "', '" + i.description + "', '" + i.note + "', '" + i.hargaAsli +
                                     "', '" + i.hargaMaterial + "', '" + i.hargaOngkosCetak + "', '" + deadline +
                                     "', '" + printApproval + "', '" + printApprovalImage + "', '" + printApprovalSigner +
                                     "', 'none', '" + i.digitalCounter + "', '" + i.offsetCounter + "')");

                        foreach (string[] j in i.finishing)
                        {
                            ExecuteQuery("INSERT INTO PrintingSalesDetailFinishing(printingSalesID, printingType, printingTitle, finishingType, detail, note, process) " +
                                         "VALUES " +
                                         "('" + tbNoJob.Text + "', '" + i.printingType + "', '" + i.printingTitle + "', '" + j[0] + "', '" + j[1] + "', '" + j[2] + "', '0')");
                        }
                    }
                    closeWindow();
                }
            }
        }