Ejemplo n.º 1
0
        void KeyF9() 
        {
            gridView1.PostEditor();
            gridView1.UpdateCurrentRow();
            int ctyp = 0;
            if (lookupcustomer.EditValue != null)
            {
                 ctyp = int.Parse(lookupcustomer.GetColumnValue("CUSTOMERTYPE").ToString());
            }
            var frm = new CashCollected();
            frm.iscredit = ctyp == 2;
            frm.ShowDialog();

            if (!frm.issucess)
                return;
            var _paytype = frm.paytype1;
            try
            {
                if (decimal.Parse(txtnetamt.EditValue.ToString()) != 0 || decimal.Parse(txtreturnamt.EditValue.ToString())!= 0)
                {
                    var f = new AmtCollection();
                    var dt = new BLSales().GetSalesInvMain(txtinvoiceno.Text, false, false);
                    DsInventory.SALESMAINRow dr = null;
                    sALESINVDETAILBindingSource.EndEdit();
                    f.Salesinvdetail = dsInventory1.SALESINVDETAIL;
                    if (dt.Rows.Count == 0)
                    {
                        dr = (DsInventory.SALESMAINRow)dt.NewRow();
                    }
                    else
                    {
                        dr = (DsInventory.SALESMAINRow)dt.Rows[0];
                    }
                    dr.SINVNO = txtinvoiceno.Text;
                    dr.CUSTOMERID = lookupcustomer.EditValue == null ? null : lookupcustomer.EditValue.ToString();
                    dr.CUSTNAME = lookupcustomer.EditValue == null ? "Cash" : lookupcustomer.Text;
                    dr.SALESTYPE = "A";
                    if (ctyp == 1)
                        {
                            dr.SALESTYPE = "I";
                            dr.CUSTOMERFIXDISC = int.Parse(cmbclass.GetColumnValue("COMPDISC").ToString());
                            dr.CARDID = txtfileno.EditValue == null? 0: int.Parse(txtfileno.EditValue.ToString());
                            dr.CARDNO = txtvisitno.EditValue == null?0: int.Parse(txtvisitno.EditValue.ToString());
                        }
                        if (ctyp == 2)
                        {
                            dr.SALESTYPE = "C";
                            f.iscredit = true;
                        }
                    dr.SDISC = txtdiscount.EditValue == null ? 0 : decimal.Parse(txtdiscount.EditValue.ToString());
                    dr.TOTALAMT = subtotal.EditValue == null ? 0 : decimal.Parse(subtotal.EditValue.ToString());
                    dr.ROUNDOFF = 0;
                    dr.NETAMT = decimal.Parse(txtnetamt.EditValue.ToString());
                    dr.RECDAMT = 0;
                    dr.SALESMAN = lookupcashier.EditValue == null ? 0 : int.Parse(lookupcashier.EditValue.ToString());
                    dr.DOCTOR = _doctorid;
                    dr.COMPANY = VIRETAILDAL.COMMON.Utils.Company;
                    dr.COMPNAME = Environment.MachineName;
                    dr.SHITFCODE = new BLSales().GetShiftCode();
                    
                    dr.ISSALE = true;
                    if (cutomerpayment.EditValue != null)
                        dr.CARDDISC = int.Parse(cutomerpayment.EditValue.ToString());
                    if (txtrounding.EditValue != null)
                        dr.ROUNDOFF = decimal.Parse(txtrounding.EditValue.ToString()) ;
                    else
                        dr.ROUNDOFF = 0;

                    if (txtreturnamt.EditValue != null)
                        dr.RETURNAMT = decimal.Parse(txtreturnamt.EditValue.ToString());
                    if (cmbclass.EditValue != null)
                        dr.GRADE = cmbclass.Text;
                    if (txtavailble.EditValue != null)
                        dr.AVAILBLEAMT = decimal.Parse(txtavailble.EditValue.ToString());
                    dr.TRANDATE = DateTime.Now;
                    if (cmbclass.EditValue != null)
                    {
                        f.NetAmount = decimal.Parse(txtnetamt.EditValue.ToString()) *
                                      (decimal.Parse(cutomerpayment.EditValue.ToString())/100);
                    }
                    else
                    {
                        f.NetAmount = decimal.Parse(txtnetamt.EditValue.ToString());
                    }
                    f.RecdAmount = f.NetAmount;
                    f.SalesmainRow = dr;
                    f.Paytype = _paytype;
                    f.ShowDialog();
                    if (f._issucess)
                    {
                        var bls = new BLSales();
                        bls.GetNonSaleInv();
                        lookupcustomer.EditValue = null;
                        if (bls.SalesmainRow != null)
                        {
                            txtinvoiceno.Text = bls.SalesmainRow[0].ToString();
                            dsInventory1.SALESINVDETAIL.Clear();
                            dsInventory1.Merge(bls.Salesinvdetail);
                            foreach (DsInventory.SALESINVDETAILRow drs in dsInventory1.SALESINVDETAIL.Rows)
                            {
                                if (!drs.IsEXPDATENull())
                                    drs["EXPDATE1"] = drs.EXPDATE.ToString("MM-yy");
                            }
                            UpdateTotal();
                        }
                        else
                        {
                            DoNew();    
                        }
                        KeyF8(false);
                        LoadSessionUsers();
                    }
                }
            }    
             catch (Exception op)
             {
                 XtraMessageBox.Show(op.ToString(), "POS", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
        }
Ejemplo n.º 2
0
        void KeyF9()
        {
            gridView1.PostEditor();
            gridView1.UpdateCurrentRow();
            UpdateTotal();
            int ctyp = 10;
            if (decimal.Parse(subtotal.EditValue.ToString()) == 0 && decimal.Parse(txtreturnamt.EditValue.ToString())==0)
            {
                onePing();
                txtbarcode.Focus();
                return;
            }

            if (lookupcustomer.EditValue != null)
            {
                ctyp = int.Parse(lookupcustomer.GetColumnValue("CUSTOMERTYPE").ToString());
            }

            if (ctyp == 1)
             {
                if(cmbclass.EditValue==null)
                {
                    onePing();
                    cmbclass.ErrorText = "Please select class";
                    cmbclass.Focus();
                    return;
                }
                 cmbclass.ErrorText = null;
                 var t = string.IsNullOrEmpty(cutomerpayment.EditValue.ToString())
                             ? 0
                             : decimal.Parse(cutomerpayment.EditValue.ToString());
                 if(t<0)
                    {
                        onePing();
                        cutomerpayment.ErrorText = "Please enter customer share";
                        cutomerpayment.Focus();
                        return;
                    }
                 cutomerpayment.ErrorText = null;
             }

            var _paytype = 0;
            //if (decimal.Parse(txtnetamt.EditValue.ToString()) == 0)
            //{
            //    _paytype = 0;
            //}
            //else if (decimal.Parse(txtnetamt.EditValue.ToString()) <= 0 && (ctyp == 0))
            //{
            //    _paytype = 0;
            //}
            //else
            //{

           // string di = String.Format("Total = {0} ", decimal.Parse(subtotal.Text).ToString("N"));
            CustomerDisplay("Total", decimal.Parse(subtotal.Text));
            //if (ComPort.IsOpen)
            // {
            //    ComPort.Write("\f");
            //    ComPort.Write("\v");
            //    ComPort.WriteLine(String.Format("Total = {0} ", decimal.Parse(subtotal.Text).ToString("N")));
            //  }
            //  if(ComPort.IsOpen)
            //      ComPort.Close();
                var frm = new CashCollected();
                frm.Netamount = decimal.Parse(txtnetamt.EditValue.ToString());
                frm.iscredit = ctyp == 2;
                frm.ShowDialog();
                if (!frm.issucess)
                {
                   // SetUpComm();
                   return;
                }
            _paytype = frm.paytype1;
            //}
            try
            {
                if (decimal.Parse(txtnetamt.EditValue.ToString()) != 0 || decimal.Parse(txtreturnamt.EditValue.ToString()) != 0)
                {
                    var f = new AmtCollection();

                    var dt = new BLSales().GetSalesInvMain(txtinvoiceno.Caption.Trim(), false, false);
                    DsInventory.SALESMAINRow dr = null;
                    sALESINVDETAILBindingSource.EndEdit();
                    f.Salesinvdetail = dsInventory1.SALESINVDETAIL;
                    f._isRedim = _isRedim;
                    if (dt.Rows.Count == 0)
                    {
                        dr = (DsInventory.SALESMAINRow)dt.NewRow();
                    }
                    else
                    {
                        dr = (DsInventory.SALESMAINRow)dt.Rows[0];
                    }
                    dr.SINVNO = txtinvoiceno.Caption.Trim();
                    dr.CUSTOMERID = lookupcustomer.EditValue == null ? null : lookupcustomer.EditValue.ToString();
                    dr.CUSTNAME = lookupcustomer.EditValue == null ? "Cash" : lookupcustomer.Text;
                    dr.SALESTYPE = "A";
                    if (ctyp == 0)
                    {
                        dr.SALESTYPE = "M";
                    }
                    if (ctyp == 1)
                    {
                        dr.SALESTYPE = "I";
                        dr.CUSTOMERFIXDISC = decimal.Parse(cmbclass.GetColumnValue("COMPDISC").ToString());//decimal.Parse(cutomerpayment.EditValue.ToString());
                        dr.CARDID = txtfileno.EditValue == null ? 0 : int.Parse(txtfileno.EditValue.ToString());
                        dr.CARDNO = txtvisitno.EditValue == null ? 0 : int.Parse(txtvisitno.EditValue.ToString());
                        
                            dr.CUSTNAME = lookupcustomer.Text + "-" + txtpatname.Text;
                    }
                    if (ctyp == 2)
                    {
                        dr.SALESTYPE = "C";
                        f.iscredit = true;
                    }
                    dr.SDISC = txtdiscount.EditValue == null ? 0 : decimal.Parse(txtdiscount.EditValue.ToString());
                    dr.TOTALAMT = subtotal.EditValue == null ? 0 : decimal.Parse(subtotal.EditValue.ToString());
                    dr.ROUNDOFF = 0;
                    dr.NETAMT = decimal.Parse(txtnetamt.EditValue.ToString());
                    dr.RECDAMT = 0;
                    dr.SALESMAN = lookupcashier.EditValue == null ? 0 : int.Parse(lookupcashier.EditValue.ToString());
                    dr.DOCTOR = _doctorid;
                    dr.COMPANY = Utils.Company;
                    dr.COMPNAME = Environment.MachineName;
                    dr.SHITFCODE = new BLSales().GetShiftCode();

                    dr.ISSALE = true;
                    if (cutomerpayment.EditValue != null)
                        dr.CARDDISC = decimal.Parse(cutomerpayment.EditValue.ToString());
                    if (txtrounding.EditValue != null)
                        dr.ROUNDOFF = decimal.Parse(txtrounding.EditValue.ToString());
                    else
                        dr.ROUNDOFF = 0;

                    if (txtreturnamt.EditValue != null)
                        dr.RETURNAMT = decimal.Parse(txtreturnamt.EditValue.ToString());
                    if (cmbclass.EditValue != null)
                        dr.GRADE = cmbclass.Text;
                    if (txtavailble.EditValue != null)
                        dr.AVAILBLEAMT = decimal.Parse(txtavailble.EditValue.ToString());
                    dr.TRANDATE = DateTime.Now;
                    if (cmbclass.EditValue != null)
                    {
                        f.NetAmount = decimal.Parse(txtnetins.EditValue.ToString());  //decimal.Parse(txtnetamt.EditValue.ToString()) * (decimal.Parse(cutomerpayment.EditValue.ToString()) / 100);
                    }
                    else
                    {
                        f.NetAmount = decimal.Parse(txtnetamt.EditValue.ToString());
                    }
                    f.RecdAmount = f.NetAmount;
                    f.SalesmainRow = dr;
                    f.Paytype = _paytype;

                    f.ShowDialog();
                    if (f._issucess)
                    {
                        _isRedim = false;
                        barButtonItem14.Caption = "Shitf Code = " + new BLSales().GetShiftCode();
                        if (ctyp == 0)
                        {
                            var p = new BLSales().GetShiftCode("POINTS");
                            if (!string.IsNullOrEmpty(p))
                            {
                                if (decimal.Parse(p) > 0)
                                {
                                    decimal epoints = Math.Round(dr.NETAMT/decimal.Parse(p), 2);
                                    new BlCustomer().UpdateCustomerPoints(dr.CUSTOMERID, epoints);
                                }
                            }
                        }
                        txtinvoiceno.Caption = string.Empty;
                        DoNew();
                        KeyF8(false);
                        lblmutilpleprice.Visible = false;
                        UpdateTotal();
                        LoadSessionUsers();
                        cls.DisplayComm("Next Customer", string.Empty);
                    }
                    else
                    {
                        XtraMessageBox.Show("Error Sale Not Completed ", "POS", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception op)
            {
                XtraMessageBox.Show(op.ToString(), "POS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }