Exemplo n.º 1
0
        private void InsertOtherTotal(string custType_, int Quantity)
        {
            int    K16, BTL;
            string baseid;

            sinarekDataSet.productbaseDataTable dt = new sinarekDataSet.productbaseDataTable();
            using (sinarekDataSetTableAdapters.productbaseTableAdapter tbl = new sinarekDataSetTableAdapters.productbaseTableAdapter())
            {
                tbl.Fill(dt);
            }
            using (sinarekDataSetTableAdapters.producttotalTableAdapter tbl = new sinarekDataSetTableAdapters.producttotalTableAdapter())
            {
                switch (custType_.ToLower())
                {
                case "jadi":
                    baseid = dt.Select("productshort = 'BK'and unitshort = 'K100'")[0]["Baseid"].ToString();
                    K16    = Math.DivRem((Quantity * 100), 16, out BTL);
                    tbl.InsertProductTotal(dtpTanggal.Value
                                           , "", "JADI KARUNG", "", int.Parse(baseid), Quantity, "", NBConfig.ValidUserName);
                    baseid = dt.Select("productshort = 'BK' and unitshort = 'K16'")[0]["Baseid"].ToString();
                    tbl.InsertProductTotal(dtpTanggal.Value
                                           , "", "JADI KARUNG", "", int.Parse(baseid), -1 * K16, "", NBConfig.ValidUserName);
                    baseid = dt.Select("productshort = 'BK' and unitshort = 'BTL'")[0]["Baseid"].ToString();
                    tbl.InsertProductTotal(dtpTanggal.Value
                                           , "", "JADI KARUNG", "", int.Parse(baseid), -1 * BTL, "", NBConfig.ValidUserName);
                    break;

                case "rusak":
                    K16    = Math.DivRem(Quantity, 16, out BTL);
                    baseid = dt.Select("productshort = 'BK' and unitshort = 'K16'")[0]["Baseid"].ToString();
                    tbl.InsertProductTotal(dtpTanggal.Value
                                           , "", "BARANG RUSAK", "", int.Parse(baseid), K16, "", NBConfig.ValidUserName);
                    baseid = dt.Select("productshort = 'BK' and unitshort = 'BTL'")[0]["Baseid"].ToString();
                    tbl.InsertProductTotal(dtpTanggal.Value
                                           , "", "BARANG RUSAK", "", int.Parse(baseid), BTL, "", NBConfig.ValidUserName);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            //TODO: After print update total in db
            //If total existed then delete and insert new one
            DialogResult res = RadMessageBox.Show("Siapkan kertas untuk print.", "SMS - Verification"
                                                  , MessageBoxButtons.OKCancel
                                                  , RadMessageIcon.Question);

            if (res == System.Windows.Forms.DialogResult.OK)
            {
                PrinterSettings printerSettings;
                ReportProcessor reportProcessor;

                rptBotolKotor rpt = new rptBotolKotor();
                rpt.ReportParameters["user"].Value    = NBConfig.ValidUserName;
                rpt.ReportParameters["tanggal"].Value = dtpTanggal.Value;
                //rpt.ReportParameters["custtypetoid"].Value = custtypetoid;

                IReportDocument iRpt = (IReportDocument)rpt;
                //// PrinterSettings
                printerSettings = new PrinterSettings();

                try
                {
                    InstanceReportSource reportSource = new InstanceReportSource();
                    reportSource.ReportDocument = iRpt;

                    reportProcessor = new ReportProcessor();
                    reportProcessor.PrintReport(reportSource, printerSettings);
                    helper.PrintLog(this.GetType().Name, rpt.Name, this.Text + ":tanggal-" + dtpTanggal.Value.ToString());
                }
                catch (Exception ex)
                {
                    helper.ErrorMessage(ex.Message);
                }


                sinarekDataSet.productbaseDataTable dt = new sinarekDataSet.productbaseDataTable();
                using (sinarekDataSetTableAdapters.productbaseTableAdapter tbl = new sinarekDataSetTableAdapters.productbaseTableAdapter())
                {
                    tbl.Fill(dt);
                }

                using (sinarekDataSetTableAdapters.producttotalTableAdapter tbl = new sinarekDataSetTableAdapters.producttotalTableAdapter())
                {
                    foreach (GridViewSummaryItem item in radGridView1.SummaryRowsBottom[0])
                    {
                        if (item.Name != "NoSJ" && item.Name != "Total")
                        {
                            string baseid = dt.Select("productshort = 'BK' and unitshort = '" + item.Name + "'")[0]["baseid"].ToString();
                            string obj    = item.Evaluate(radGridView1.MasterTemplate).ToString();
                            tbl.InsertProductTotal(dtpTanggal.Value
                                                   , ""
                                                   , "AKHIR"
                                                   , ""
                                                   , int.Parse(baseid)
                                                   , decimal.Parse(obj)
                                                   , "", NBConfig.ValidUserName);
                        }
                    }
                }
            }
        }