예제 #1
0
        public string DoDeleteInvoice(Ledgers.ARAPRECEIPTSDETAILSRow dr)
        {
            SqlTransaction tran = null;
            var isnew = false;
            string retval = string.Empty;
            try
            {
                var cn = new SqlConnection(_constr);
                cn.Open();
                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);

                var taLedger = new LEDGERSTableAdapter();

                taLedger.AssignConnection(cn, tran);

                //ARAPRECEIPTSDETAILS
                            //    var cmd = new SqlCommand(cmdtxt, cn, tran);
                var cmd = new SqlCommand();
                cmd.Connection = cn;
                cmd.Transaction = tran;


                var cmdtxt = "delete from  ARAPRECEIPTSDETAILS where tranid  = " + dr.TRANID + "";

                cmd.CommandText = cmdtxt;
                cmd.ExecuteNonQuery();

                cmdtxt = "update ARAPRECEIPTS set AMOUNT = AMOUNT - " + dr.INVAMOUNT + " where   ARAPTRANID =" + dr.ARAPTRANID;

                                cmd.CommandText = cmdtxt;
                cmd.ExecuteNonQuery();

                cmdtxt = "update APARMAIN set BALANCE = " + dr.INVAMOUNT + " , PAIDAMOUNT = 0 where  tranid = " + dr.TRANID;

                cmd.CommandText = cmdtxt;
                cmd.ExecuteNonQuery();


                taLedger.Insert("S", dr.REFNO, DateTime.Now.Date, dr.INVOICEDATE, dr.ARAPTRANID, dr.INVOICENO,
                    - dr.INVAMOUNT, 0, 18, Utils.Company, Utils.Userid, "Purchase Reverse");
                tran.Commit();
                retval = "1";
            }
            catch (Exception ex)
            {
                tran.Rollback();
                retval = ex.ToString();
            }
            return retval;
        }
예제 #2
0
        public string DoPost(string batchno,Ledgers.ARAPRECEIPTSDETAILSDataTable dt)
        {
            string retval = string.Empty;
            SqlTransaction tran = null;
            try
            {
                var cn = new SqlConnection(_constr);
                cn.Open();
                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);

                var ta = new ARAPRECEIPTSTableAdapter();
                var tadet = new ARAPRECEIPTSDETAILSTableAdapter();

                var taLedger = new LEDGERSTableAdapter();
                 ta.AssignConnection(cn,tran);// tadet.AssignConnection(cn,tran);
               
                taLedger.AssignConnection(cn,tran);
                string arapno = string.Empty;
                foreach (Ledgers.ARAPRECEIPTSDETAILSRow drdet in dt.Rows)
                {
                            if (drdet.RowState != DataRowState.Deleted)
                            {
                                arapno = drdet.ARAPTRANID;
                                var cmdtxt = "update APARMAIN set PAIDAMOUNT = 0 , BALANCE =  INVAMOUNT where  TRANID = " + drdet.TRANID;
                                var cmd = new SqlCommand(cmdtxt, cn, tran);
                                cmd.ExecuteNonQuery();
                                taLedger.Insert("S", drdet.REFNO, DateTime.Now.Date, drdet.INVOICEDATE, batchno,
                                drdet.INVOICENO, - drdet.INVAMOUNT, 0, 18, Utils.Company, Utils.Userid,"Payment Reverse");
                            }
                 }
                tran.Commit();
                //tadet.DeleteByARAPTRANID(batchno);
                //ta.DeleteByARAPTRANID(batchno);
                 ta.DoPost(batchno);
                
                retval = "1";
               
                
            }
            catch (Exception ex)
            {
                if (tran != null) tran.Rollback();
                retval = ex.ToString();
            }
            return retval;
        }