public JsonResult save_IPBill_Correction(int serid, long billno, BillAddSaveParams IPB)
        {
            IPBillCorrectionDB _DB = new IPBillCorrectionDB();

            if (_DB.save_ipbill_corrections(OperatorId, serid, billno, IPB))
            {
                return(Json(new { rcode = 0, rmsg = _DB.retmsg }));
            }
            else
            {
                return(Json(new { rcode = _DB.ret, rmsg = _DB.retmsg }));
            }
        }
        /* Saving IP Bill Added Items */

        public bool save_ipbill_corrections(int opeid, int serid, long billno, BillAddSaveParams IPB)
        {
            try
            {
                //spoken language
                DataTable dtIPBILL = new DataTable();
                dtIPBILL.Columns.AddRange(new[] {
                    new DataColumn("ItemId", typeof(long)),
                    new DataColumn("Quantity", typeof(int)),
                    new DataColumn("MarkUpAmount", typeof(long)),
                    new DataColumn("Discount", typeof(long)),
                    new DataColumn("DiscLevel", typeof(int)),
                    new DataColumn("DeductableAmount", typeof(long)),
                    new DataColumn("DedLevel", typeof(int)),
                    new DataColumn("DeptId", typeof(int)),
                    new DataColumn("BillDate", typeof(string)),
                    new DataColumn("Price", typeof(long)),
                    new DataColumn("ItemCode", typeof(string)),
                    new DataColumn("ItemName", typeof(string))
                });
                System.IO.StringWriter dt = new System.IO.StringWriter();
                if (IPB.billaddparam != null && IPB.billaddparam.Count > 0)
                {
                    var items = IPB.billaddparam.Select(i => new BillAddItemList
                    {
                        ItemId           = i.ItemId,
                        Quantity         = i.Quantity,
                        MarkUpAmount     = i.MarkUpAmount,
                        Discount         = i.Discount,
                        DiscLevel        = i.DiscLevel,
                        DeductableAmount = i.DeductableAmount,
                        DedLevel         = i.DedLevel,
                        DeptId           = i.DeptId,
                        BillDate         = i.BillDate,
                        Price            = i.Price,
                        ItemCode         = i.ItemCode,
                        ItemName         = i.ItemName
                    }).ToList();

                    foreach (var item in items)
                    {
                        DataRow newRow = dtIPBILL.NewRow();
                        newRow["ItemId"]           = item.ItemId;
                        newRow["Quantity"]         = item.Quantity;
                        newRow["MarkUpAmount"]     = item.MarkUpAmount;
                        newRow["Discount"]         = item.Discount;
                        newRow["DiscLevel"]        = item.DiscLevel;
                        newRow["DeductableAmount"] = item.DeductableAmount;
                        newRow["DedLevel"]         = item.DedLevel;
                        newRow["DeptId"]           = item.DeptId;
                        newRow["BillDate"]         = item.BillDate;
                        newRow["Price"]            = item.Price;
                        newRow["ItemCode"]         = item.ItemCode;
                        newRow["ItemName"]         = item.ItemName;
                        dtIPBILL.Rows.Add(newRow);
                    }
                    dtIPBILL.TableName = "DTXMLDATA";
                    dtIPBILL.WriteXml(dt);
                }


                DB.param = new SqlParameter[] {
                    new SqlParameter("@serid", serid),
                    new SqlParameter("@billno", billno),
                    new SqlParameter("@opeid", opeid),
                    new SqlParameter("@XMLDATA", dt == null ? (object)DBNull.Value : dt.ToString()),
                };

                //DB.param[75].Direction = ParameterDirection.Output;
                DB.ExecuteSPAndReturnDataTable("ARIPBILLING.save_ipbill_additem");
                // this.QResult = DB.param[75].Value.ToString();
                //this.ErrorMessage = DB.param[7].Value.ToString();
                // if (!string.IsNullOrEmpty(DB.param[7].Value.ToString()))
                //  return false;
                ret    = 0;
                retmsg = "Data Successfully Saved!";
                return(true);
            }
            catch (Exception ex)
            {
                ret    = -1;
                retmsg = ex.Message;
                eLOG.LogError(ex);
                return(false);

                throw new ApplicationException("Error Message:</b> <br /> " + ex.Message + "<br /><br /><b>Stack Trace:</b><br /> " + ex.StackTrace);
            }
        }