コード例 #1
0
        private void commandButton2_Click(object sender, EventArgs e)
        {
            if (this.Caller is FrmPOS)
            {
                double RpNota = 0, RpBayar = 0;
                RpNota  = Convert.ToDouble(Tools.isNull(TxtNeto.Text, "0").ToString());
                RpBayar = Convert.ToDouble(Tools.isNull(textBox2.Text, "0").ToString());

                if (RpNota == 0)
                {
                    MessageBox.Show("Rp Nota Kosong");
                    return;
                }
                if (RpBayar == 0)
                {
                    MessageBox.Show("Rp Bayar Kosong");
                    return;
                }

                /*ditutup, pembayaran dikembalikan ke penjualantunai*/
                //if (RpNota > RpBayar)
                //{
                //    MessageBox.Show("Pembayaran kurang.");
                //    return;
                //}

                //if (RpNota > 0) // && RpBayar > 0)
                //{
                POS.FrmPOS frmCaller = (POS.FrmPOS) this.Caller;
                frmCaller.txtBayar.Text = Convert.ToDouble(Tools.isNull(textBox2.Text, "0")).ToString("N0");
                frmCaller.Save_DONOTA(sender, e);
                LblNota.Text = frmCaller.LblNoNota.Text.ToString();

                if (_isCetakNota)
                {
                    if (!frmCaller.PengajuanHarga)
                    {
                        DialogResult dialogResult = MessageBox.Show("Data dengan Nomor Nota : " + Convert.ToString(LblNota.Text) + ", Nomor DO : " + Convert.ToString(LblNota.Text) + " Telah Disimpan" + "\n\n\n" + "CETAK NOTA ?", "KONFIRMASI", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        if (dialogResult == DialogResult.Yes)
                        {
                            CmdPrint_Click(sender, e);
                            this.Close();
                        }
                        else if (dialogResult == DialogResult.No)
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        this.Close();
                    }
                    POS.FrmPOS ifrmChild = new POS.FrmPOS();
                    ifrmChild.MdiParent = Program.MainForm;
                    Program.MainForm.RegisterChild(ifrmChild);
                    ifrmChild.Show();
                }
                else
                {
                    this.Close();
                }
                //}
            }

            else if (this.Caller is FrmPOS0401)
            {
                POS.FrmPOS0401 frmCaller = (POS.FrmPOS0401) this.Caller;
                frmCaller.Save_DONOTA(sender, e);
                LblNota.Text = frmCaller.LblNoNota.Text.ToString();

                if (_isCetakNota)
                {
                    DialogResult dialogResult = MessageBox.Show("Data dengan Nomor Nota : " + Convert.ToString(LblNota.Text) + ", Nomor DO : " + Convert.ToString(LblNota.Text) + " Telah Disimpan" + "\n\n\n" + "CETAK NOTA ?", "KONFIRMASI", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        CmdPrint_Click(sender, e);
                        this.Close();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        this.Close();
                    }

                    POS.FrmPOS0401 ifrmChild = new POS.FrmPOS0401();
                    ifrmChild.MdiParent = Program.MainForm;
                    Program.MainForm.RegisterChild(ifrmChild);
                    ifrmChild.Show();
                }
                else
                {
                    this.Close();
                }
            }

            else if (this.Caller is FrmPOSbengkel)
            {
                POS.FrmPOSbengkel frmCaller = (POS.FrmPOSbengkel) this.Caller;
                frmCaller.Save_DONOTA(sender, e);
                LblNota.Text      = frmCaller.LblNoNota.Text.ToString();
                this.DialogResult = DialogResult.OK;

                if (_isCetakNota)
                {
                    DialogResult dialogResult = MessageBox.Show("Data dengan Nomor Nota : " + Convert.ToString(LblNota.Text) + ", Nomor DO : " + Convert.ToString(LblNota.Text) + " Telah Disimpan" + "\n\n\n" + "CETAK NOTA ?", "KONFIRMASI", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        CmdPrint_Click(sender, e);
                        this.Close();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        this.Close();
                    }

                    POS.FrmPOSbengkel ifrmChild = new POS.FrmPOSbengkel();
                    ifrmChild.MdiParent = Program.MainForm;
                    Program.MainForm.RegisterChild(ifrmChild);
                    ifrmChild.Show();
                }
                else
                {
                    this.Close();
                }
            }
            label1.Visible  = true;
            LblNota.Visible = true;
            // CmdPrint.Enabled = true;
        }