void DoSave() { var bl = new BLSales(); var ret = bl.DoSave(txtinvoiceno.Text, false,lookupcashier.EditValue==null?0:int.Parse(lookupcashier.EditValue.ToString()), _doctorid); if(ret!="1") { XtraMessageBox.Show(ret, "POS", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); } }
void DoTaKePayment(bool isprintinv=false) { simpleButton1.Enabled = false; try { if (txtcard1.EditValue != null) { if (decimal.Parse(txtcard1.EditValue.ToString()) > 0) SalesmainRow.CREDICARDTNO = txtcard1.Text; } else { SalesmainRow.CREDICARDTNO = ""; } var cashamt = txtcash.EditValue == null ? 0: decimal.Parse(txtcash.EditValue.ToString()) - decimal.Parse(txtbal.EditValue.ToString()); var creditamt = txtaccount.EditValue == null ? 0 : decimal.Parse(txtaccount.EditValue.ToString()); var spancard = txtspan.EditValue == null ? 0 : decimal.Parse(txtspan.EditValue.ToString()); var creditcardamt = txtcredit.EditValue == null ? 0 : decimal.Parse(txtcredit.EditValue.ToString()); //var roundingamt = txtrounding.EditValue == null ? 0 : decimal.Parse(txtrounding.EditValue.ToString()); SalesmainRow.CASHAMOUNT = cashamt; SalesmainRow.CARDAMOUNT = creditcardamt + spancard; SalesmainRow.CREDITAMT = creditamt; //SalesmainRow.ROUNDOFF = roundingamt; SalesmainRow.RECDAMT = cashamt; SalesmainRow.CREDICARDTYPE = paytype1; SalesmainRow.ISSALE = true; SalesmainRow.POSTED = true; SalesmainRow.HOLDDEFAULT = false; SalesmainRow.HOLDNO = 0; //dr.CUSTOMERID = lookupcustomer.EditValue == null ? null : lookupcustomer.EditValue.ToString(); //dr.CUSTNAME = lookupcustomer.EditValue == null ? "Cash" : lookupcustomer.SelectedText; if (NetAmount == cashamt) { SalesmainRow.INVAMTTYPE = 1; // SalesmainRow.SALESTYPE = "A"; } else if (NetAmount == creditamt) { SalesmainRow.INVAMTTYPE = 2; SalesmainRow.CARDNO = 0; } else if (NetAmount == spancard) SalesmainRow.INVAMTTYPE = 3; else if (NetAmount == creditcardamt) SalesmainRow.INVAMTTYPE = 3; else if (NetAmount < 0) { SalesmainRow.INVAMTTYPE = 4; } else { SalesmainRow.INVAMTTYPE = 5; } if (txtcard1.EditValue != null) { SalesmainRow.CREDICARDTNO = txtcard1.Text; } //// if (cashamt > 0) { AddRow(cashamt, 1); } if (cashamt < 0) { AddRow(cashamt, 1); } if (creditcardamt > 0) { AddRow(creditcardamt, 2); } if (creditcardamt < 0) { AddRow(creditcardamt, 2); } if (spancard > 0) { AddRow(spancard, 2); } if (spancard < 0) { AddRow(spancard, 2); } if (creditamt > 0) { AddRow(creditamt, 3); } if (creditamt < 0) { AddRow(creditamt, 3); } if (SalesmainRow.SALESTYPE == "I") { /* oLD cal var companydisc = (SalesmainRow.NETAMT) * (Convert.ToDecimal(SalesmainRow.CARDDISC) / 100); var companydisc = (SalesmainRow.NETAMT) * (SalesmainRow.CUSTOMERFIXDISC / 100); var amt = companydisc - companydisc * (Convert.ToDecimal(SalesmainRow.CARDDISC) / 100); */ //var act = (SalesmainRow.NETAMT) * (Convert.ToDecimal(SalesmainRow.CARDDISC) / 100); //var netamt = (SalesmainRow.NETAMT) * (SalesmainRow.CUSTOMERFIXDISC / 100); var companydisc = (SalesmainRow.NETAMT)*(SalesmainRow.CUSTOMERFIXDISC/100);// var amt = companydisc - companydisc * (Convert.ToDecimal(SalesmainRow.CARDDISC) / 100); // var amt = SalesmainRow.NETAMT - (act + netamt); /* New cal var compdisc = SalesmainRow.NETAMT * (Convert.ToDecimal(SalesmainRow.CUSTOMERFIXDISC) / 100);*/ var customerdisc = (SalesmainRow.NETAMT - companydisc)* (Convert.ToDecimal(SalesmainRow.CARDDISC)/100); var amt1 = SalesmainRow.NETAMT - companydisc - customerdisc; AddRow(amt1, 3); creditamt = amt1; } // RETURN if (cashamt < 0) { AddRow(-1*(SalesmainRow.TOTALAMT + SalesmainRow.RETURNAMT), 5); } if (SalesmainRow.RETURNAMT < 0) { AddRow(-1*SalesmainRow.RETURNAMT, 6); } // non calu if (SalesmainRow.SDISC > 0) { if (_isRedim) { AddRow(SalesmainRow.SDISC, 7); } else { AddRow(SalesmainRow.SDISC, 7); } } if (SalesmainRow.ROUNDOFF != 0) { AddRow(SalesmainRow.ROUNDOFF, 8); } //Assign Cost value new BLSales().UpdateCostprice(ref Salesinvdetail); var profit = new BLSales().CaluculateProfitValue(Salesinvdetail); if (NetAmount > 0) { AddRow(profit, 9); // AddRow((profit / NetAmount *100), 10); } SalesmainRow.TRANDATE = DateTime.Now; SalesmainRow.CREDITAMT = creditamt; // SalesmainRow.ROUNDOFF = roundingamt; SalesmainRow.HOLDNO = 0; SalesmainRow.HOLDDEFAULT = false; var bl = new BLSales { Salesinvdetail = Salesinvdetail, SalesmainRow = SalesmainRow, SalesAmount = dt }; var ret = bl.DoSave(); if (ret == "1") { if (_isRedim) { bl.UpdatePointsDetails(SalesmainRow.CUSTOMERID,SalesmainRow.SDISC * 100,SalesmainRow.COMPANY,SalesmainRow.TRANDATE,SalesmainRow.SINVNO,SalesmainRow.SDISC); } _issucess = true; panel2.Visible = false; btnok.Focus(); if (Utils.DefaultPrinterRow["ISDEFAULT"].ToString() == bool.TrueString) bl.DoSlipPrint(SalesmainRow.SINVNO); } else { _issucess = false; XtraMessageBox.Show(ret, "POS", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { XtraMessageBox.Show(ex.ToString(), "POS", MessageBoxButtons.OK, MessageBoxIcon.Error); } }