コード例 #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            Graphics bill = this.CreateGraphics();

            bmp = new Bitmap(this.Size.Width - 15, this.Size.Height - 315, bill);
            Graphics img = Graphics.FromImage(bmp);

            img.CopyFromScreen(this.Location.X + 7, this.Location.Y + 220, 0, 0, this.Size);
            BillPrintPreview.ShowDialog();
        }
コード例 #2
0
ファイル: Frm_POS.cs プロジェクト: swamisivakumar/POS
        private void savesmartPos1()
        {
            try
            {
                if (string.IsNullOrEmpty(txtSAmount.Text) || dataGridView4.Rows.Count <= 0)
                {
                    FrmMessage.Show("You cannot Generate Bill without Items");
                }
                else if (string.IsNullOrEmpty(textBox12.Text) || string.IsNullOrEmpty(textBox19.Text))
                {
                    FrmMessage.Show("Redeem Card No should be Entered or Cancel the Redeem");
                }
                else
                {
                    sqlhelper = new SQLHelper();
                    bool result;

                    //result = sqlhelper.ExecuteNonQuery("insert into Customers(CustName,Phone) values ('" + txtCustName.Text + "'," + txtCustPhnNo.Text + ")");
                    //if (result == true)
                    //{

                    DataSet ds = new DataSet();
                    int     count;
                    ds = sqlhelper.ExecuteQueries("select TranNo from TransactionNo");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["TranNo"].ToString()))
                        {
                            count = 1;
                        }
                        else
                        {
                            count = int.Parse(ds.Tables[0].Rows[0]["TranNo"].ToString()) + 1;
                        }
                    }
                    else
                    {
                        count = 1;
                    }

                    string todaysDate = sqlhelper.ExecuteScalar("select format(date(),'ddmmyyyy')");
                    trnNo  = todaysDate + count;
                    result = sqlhelper.ExecuteNonQuery("insert into Payment(TransactionNo,TotalAmount,DiscountAmount,BillPaid,CreatedBy)" +
                                                       "values ('" + trnNo + "','" + txtSTotal.Text + "','" + txtSDiscount.Text + "', '" + txtSAmount.Text + "'," +
                                                       "" + GlobalData.UserID + ")");

                    result = sqlhelper.ExecuteNonQuery("insert into TaxHistory(TransactionNo,TotalAmount,DiscountAmount,BillPaid,VATAmount,Paid,CreatedBy)" +
                                                       "values ('" + trnNo + "','" + txtSTotal.Text + "','" + txtSDiscount.Text + "', '" + txtSAmount.Text + "','" + SVatAmt.Text + "', '" + SDue.Text + "'," +
                                                       "" + GlobalData.UserID + ")");

                    if (result == true)
                    {
                        string PaymentId = sqlhelper.ExecuteScalar("select max(PaymentID) from Payment");

                        for (int i = 0; i < dataGridView4.Rows.Count; i++)
                        {
                            result = sqlhelper.ExecuteNonQuery("insert into Transactions(PaymentID,Barcode,CategoryID,ItemID,SaleQty,VatPercent,ItemPrice,CreatedBy)" +
                                                               "values (" + PaymentId + ",'" + dataGridView4.Rows[i].Cells["Barcode"].Value.ToString() + "'," + dataGridView4.Rows[i].Cells["CategoryID"].Value.ToString() + "," +
                                                               "" + dataGridView4.Rows[i].Cells["ItemID"].Value.ToString() + "," + dataGridView4.Rows[i].Cells["Qty"].Value.ToString() + "," +
                                                               "" + dataGridView4.Rows[i].Cells["Vat(%)"].Value.ToString() + "," + dataGridView4.Rows[i].Cells["Price"].Value.ToString() + "," + GlobalData.UserID + ")");

                            result = sqlhelper.ExecuteNonQuery("Update Stock Set StockQuantity = (StockQuantity - " + dataGridView4.Rows[i].Cells["Qty"].Value.ToString() + ")" +
                                                               " where CategoryID= " + dataGridView4.Rows[i].Cells["CategoryID"].Value.ToString() + " and  " +
                                                               "ItemID=" + dataGridView4.Rows[i].Cells["ItemID"].Value.ToString() + " and Barcode='" + dataGridView4.Rows[i].Cells["Barcode"].Value.ToString() + "'");
                        }


                        result = sqlhelper.ExecuteNonQuery("insert into RewardPoints(Points, PACNO)" +
                                                           "values (" + textBox15.Text + "," + textBox19.Text + ")");


                        if (redeemclick == true)
                        {
                            result = sqlhelper.ExecuteNonQuery("insert into RewardPointsUsed(TransactionNo, PACNO, POINTSUSED)" +
                                                               "values (" + trnNo + "," + textBox19.Text + "," + textBox18.Text + ")");

                            result = sqlhelper.ExecuteNonQuery("insert into RewardPoints(Points, PACNO)" +
                                                               "values (" + "-" + textBox18.Text + "," + textBox19.Text + ")");
                        }

                        if (result == true)
                        {
                            if (checkBox8.Checked == true)
                            {
                                if (string.IsNullOrEmpty(textBox64.Text))
                                {
                                }
                                else
                                {
                                    result = sqlhelper.ExecuteNonQuery("insert into DEALERCREDIT(DealerID,TransactionNo,TotalAmount,DiscountAmount,AfterDiscount,VATAmount,TOTALDUE,CreatedBy,STATUS)" +
                                                                       "values ('" + DEALERID + "','" + trnNo + "','" + txtSTotal.Text + "', '" + txtSDiscount.Text + "', '" + txtSAmount.Text + "', " + SVatAmt.Text + ", " + SDue.Text + ", " + GlobalData.UserID + ", 'CREDIT')");
                                    checkBox8.Checked = false;
                                    panel24.Visible   = false;
                                    textBox62.Text    = string.Empty;
                                    textBox63.Text    = string.Empty;
                                    textBox64.Text    = string.Empty;
                                }
                            }

                            if (checkBox7.Checked == true)
                            {
                                if (string.IsNullOrEmpty(textBox61.Text))
                                {
                                }
                                else
                                {
                                    result = sqlhelper.ExecuteNonQuery("insert into AGENTEARNEDCOMISSION(ANO,TransactionNo,COMISSIONEARNED,COMISSION)" +
                                                                       "values ('" + ANO + "','" + trnNo + "','" + textBox58.Text + "', '" + textBox59.Text + "')");
                                    checkBox7.Checked = false;
                                    panel23.Visible   = false;
                                    textBox58.Text    = string.Empty;
                                    textBox59.Text    = string.Empty;
                                    textBox60.Text    = string.Empty;
                                    textBox61.Text    = string.Empty;
                                }
                            }



                            BillPrintPreview.Document = printDocument3;
                            BillPrintPreview.PrintPreviewControl.Zoom = 1;
                            BillPrintPreview.ShowDialog();

                            // BillPrint.Print();
                        }
                    }


                    FrmMessage.Show("Transaction Successful");
                    Frm_POS form = new Frm_POS
                    {
                        MdiParent = this.MdiParent,
                        Anchor    = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                           | System.Windows.Forms.AnchorStyles.Left)
                                                                          | System.Windows.Forms.AnchorStyles.Right))),
                        Dock = DockStyle.Fill
                    };

                    form.Show();
                }
            }
            catch (Exception ex)
            {
                FrmMessage.Show(ex.ToString());
            }
        }
コード例 #3
0
ファイル: Frm_POS.cs プロジェクト: swamisivakumar/POS
        private void savesmartPos()
        {
            try
            {
                if (string.IsNullOrEmpty(txtSAmount.Text) || dataGridView4.Rows.Count <= 0)
                {
                    FrmMessage.Show("You cannot Generate Bill without Items");
                }

                else
                {
                    sqlhelper = new SQLHelper();
                    bool result;

                    DataSet ds = new DataSet();
                    int     count;
                    ds = sqlhelper.ExecuteQueries("select TranNo from TransactionNo");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["TranNo"].ToString()))
                        {
                            count = 1;
                        }
                        else
                        {
                            count = int.Parse(ds.Tables[0].Rows[0]["TranNo"].ToString()) + 1;
                        }
                    }
                    else
                    {
                        count = 1;
                    }

                    string todaysDate = sqlhelper.ExecuteScalar("select format(date(),'ddmmyyyy')");
                    trnNo  = todaysDate + count;
                    result = sqlhelper.ExecuteNonQuery("insert into Payment(TransactionNo,TotalAmount,DiscountAmount,BillPaid,CreatedBy)" +
                                                       "values ('" + trnNo + "','" + txtSTotal.Text + "','" + txtSDiscount.Text + "', '" + txtSAmount.Text + "'," +
                                                       "" + GlobalData.UserID + ")");

                    result = sqlhelper.ExecuteNonQuery("insert into TaxHistory(TransactionNo,TotalAmount,DiscountAmount,BillPaid,VATAmount,Paid,CreatedBy)" +
                                                       "values ('" + trnNo + "','" + txtSTotal.Text + "','" + txtSDiscount.Text + "', '" + txtSAmount.Text + "', '" + SVatAmt.Text + "', '" + SDue.Text + "'," +
                                                       "" + GlobalData.UserID + ")");


                    if (result == true)
                    {
                        //string InitCode = "";
                        //int lengthofInitCode = 0;
                        //string MaxCode;

                        string PaymentId = sqlhelper.ExecuteScalar("select max(PaymentID) from Payment");

                        for (int i = 0; i < dataGridView4.Rows.Count - 1; i++)
                        {
                            //InitCode = sqlhelper.ExecuteScalar("select CategoryInitCode from Categories where CategoryID=" + dataGridView1.Rows[i].Cells[5].Value.ToString() + "");
                            //lengthofInitCode = InitCode.Split('-')[0].Length + 1;

                            //MaxCode = sqlhelper.ExecuteScalar("SELECT Max(val(Mid([CodeNo]," + (lengthofInitCode + 1) + "))) as MaxCode FROM Transactions where CategoryID =" + dataGridView1.Rows[i].Cells[5].Value.ToString() + "");
                            //if (string.IsNullOrEmpty(MaxCode))
                            //{
                            //    MaxCode = InitCode.Split('-')[1];
                            //}
                            //InitCode = InitCode.Split('-')[0] + "-";
                            //MaxCode = InitCode + (int.Parse(MaxCode) + 1).ToString();

                            result = sqlhelper.ExecuteNonQuery("insert into Transactions(PaymentID,Barcode,CategoryID,ItemID,SaleQty,VatPercent,ItemPrice,CreatedBy)" +
                                                               "values (" + PaymentId + ",'" + dataGridView4.Rows[i].Cells["Barcode"].Value.ToString() + "'," + dataGridView4.Rows[i].Cells["CategoryID"].Value.ToString() + "," +
                                                               "" + dataGridView4.Rows[i].Cells["ItemID"].Value.ToString() + "," + dataGridView4.Rows[i].Cells["Qty"].Value.ToString() + "," +
                                                               "" + dataGridView4.Rows[i].Cells["Vat(%)"].Value.ToString() + "," + dataGridView4.Rows[i].Cells["Price"].Value.ToString() + "," + GlobalData.UserID + ")");

                            result = sqlhelper.ExecuteNonQuery("Update Stock Set StockQuantity = (StockQuantity - " + dataGridView4.Rows[i].Cells["Qty"].Value.ToString() + ")" +
                                                               " where CategoryID= " + dataGridView4.Rows[i].Cells["CategoryID"].Value.ToString() + " and  " +
                                                               "ItemID=" + dataGridView4.Rows[i].Cells["ItemID"].Value.ToString() + " and Barcode='" + dataGridView4.Rows[i].Cells["Barcode"].Value.ToString() + "'");
                        }

                        if (result == true)
                        {
                            if (checkBox8.Checked == true)
                            {
                                if (string.IsNullOrEmpty(textBox64.Text))
                                {
                                }
                                else
                                {
                                    result = sqlhelper.ExecuteNonQuery("insert into DEALERCREDIT(DealerID,TransactionNo,TotalAmount,DiscountAmount,AfterDiscount,VATAmount,TOTALDUE,CreatedBy,STATUS)" +
                                                                       "values ('" + DEALERID + "','" + trnNo + "','" + txtSTotal.Text + "', '" + txtSDiscount.Text + "', '" + txtSAmount.Text + "', " + SVatAmt.Text + ", " + SDue.Text + ", " + GlobalData.UserID + ", 'CREDIT')");
                                    checkBox8.Checked = false;
                                    panel24.Visible   = false;
                                    textBox62.Text    = string.Empty;
                                    textBox63.Text    = string.Empty;
                                    textBox64.Text    = string.Empty;
                                }
                            }

                            if (checkBox7.Checked == true)
                            {
                                if (string.IsNullOrEmpty(textBox61.Text))
                                {
                                }
                                else
                                {
                                    result = sqlhelper.ExecuteNonQuery("insert into AGENTEARNEDCOMISSION(ANO,TransactionNo,COMISSIONEARNED,COMISSION)" +
                                                                       "values ('" + ANO + "','" + trnNo + "','" + textBox58.Text + "', '" + textBox59.Text + "')");
                                    checkBox7.Checked = false;
                                    panel23.Visible   = false;
                                    textBox58.Text    = string.Empty;
                                    textBox59.Text    = string.Empty;
                                    textBox60.Text    = string.Empty;
                                    textBox61.Text    = string.Empty;
                                }
                            }


                            BillPrintPreview.Document = printDocument3;
                            BillPrintPreview.PrintPreviewControl.Zoom = 1;
                            BillPrintPreview.ShowDialog();

                            // BillPrint.Print();
                        }
                    }


                    FrmMessage.Show("Transaction Successful");


                    Frm_POS form = new Frm_POS
                    {
                        MdiParent = this.MdiParent,
                        Anchor    = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                           | System.Windows.Forms.AnchorStyles.Left)
                                                                          | System.Windows.Forms.AnchorStyles.Right))),
                        Dock = DockStyle.Fill
                    };

                    form.Show();

                    //cancelSmarttrans();
                    //textBox12.Text = string.Empty;
                    //textBox13.Text = string.Empty;
                    //textBox14.Text = string.Empty;
                    //textBox15.Text = string.Empty;
                    //SVatAmt.Text = "0";
                    ////textBox16.Text = "0";
                    //textBox18.Text = "0";
                    //txtSTotal.Text = "0";
                    //textBox19.Text = "PACNO";
                    //txtSAmount.Text = "0";


                    //button10.Visible = true;
                    //button8.Visible = false;
                }
            }
            catch (Exception ex)
            {
                FrmMessage.Show(ex.ToString());
            }
        }
コード例 #4
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtBillpaid.Text) || dataGridView1.Rows.Count <= 0)
                {
                    FrmMessage.Show("Please select atleast one service to generate a bill");
                }
                //else if (string.IsNullOrEmpty(txtCustMobile.Text.Trim()) || string.IsNullOrEmpty(txtName.Text.Trim()))
                //{
                //    FrmMessage.Show("Please enter the Customer Name and Mobile");
                //}
                else
                {
                    sqlhelp = new SQLHelper();
                    bool result = false;
                    //if (Int32.Parse(sqlhelp.ExecuteScalar("select count(Phone) from Customers where Phone='" + txtCustMobile.Text + "'")) == 0)
                    //{
                    //    result = sqlhelp.ExecuteNonQuery("insert into Customers (CustName,Phone) values('" + txtName.Text.Trim() + "','" + txtCustMobile.Text.Trim() + "')");
                    //    CustID = sqlhelp.ExecuteScalar("select max(CustID) from Customers");
                    //}
                    //else
                    //{
                    //    result = true;
                    //}
                    //if (result == true)
                    //{
                    result = sqlhelp.ExecuteNonQuery("insert into ServiceTransactions(TotalAmount,DiscountPercent,BillPaid,CreatedBy)" +
                                                     "values (" + txtGrandTotal.Text + "," + txtDiscount.Text.Trim() + ", " + txtBillpaid.Text + "," +
                                                     "" + GlobalData.UserID + ")");
                    if (result == true)
                    {
                        TransID = sqlhelp.ExecuteScalar("select max(STransID) from ServiceTransactions");

                        for (int i = 0; i < dataGridView1.Rows.Count; i++)
                        {
                            // decimal Commission = 0;
                            decimal ServiceAmount = 0;
                            ServiceAmount = (Math.Round((decimal.Parse(dataGridView1.Rows[i].Cells["Service Charge"].Value.ToString()) - (decimal.Parse(dataGridView1.Rows[i].Cells["Service Charge"].Value.ToString()) * (decimal.Parse(txtDiscount.Text) / 100))), 2));
                            // Commission = (Math.Round(((ServiceAmount * (decimal.Parse(Int32.Parse(sqlhelp.ExecuteScalar("select COMMISSION from employees where ISACTIVE=True and EMPID=" + dataGridView1.Rows[i].Cells["EMPID"].Value.ToString() + "")).ToString()) / 100))), 2));
                            result = sqlhelp.ExecuteNonQuery("insert into STransDetails(STransID,ServiceID,ServiceCharge,DiscountPercent)" +
                                                             "values (" + TransID + "," + dataGridView1.Rows[i].Cells["ServiceID"].Value.ToString() + "," + dataGridView1.Rows[i].Cells["Service Charge"].Value.ToString() + "," +
                                                             "" + txtDiscount.Text + ")");
                        }
                        if (result == true)
                        {
                            BillPrintPreview.Document = BillPrint;
                            BillPrintPreview.PrintPreviewControl.Zoom = 1;
                            BillPrintPreview.ShowDialog();
                        }
                    }



                    FrmMessage.Show("Transaction Successful");

                    FRM_SERVICEACCOUNT form = new FRM_SERVICEACCOUNT
                    {
                        MdiParent = this.MdiParent,
                        Anchor    = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                           | System.Windows.Forms.AnchorStyles.Left)
                                                                          | System.Windows.Forms.AnchorStyles.Right))),
                        Dock = DockStyle.Fill
                    };

                    form.Show();
                    //}
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }