public CLayer.SupplierInvoice getGetSupplierInvoicedetails(long ID)
        {
            CLayer.SupplierInvoice    result = new CLayer.SupplierInvoice();
            List <DataPlug.Parameter> param  = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pSupplierInvID", DataPlug.DataType._BigInt, ID));
            DataTable dt = Connection.GetTable("getGetSupplierInvoicedetails", param);

            if (dt.Rows.Count > 0)
            {
                result = new CLayer.SupplierInvoice();
                result.SupplierInvoiceID        = Connection.ToLong(dt.Rows[0]["SupplierInvoiceID"]);
                result.PropertyId               = Connection.ToLong(dt.Rows[0]["PropertyID"]);
                result.Property_Name            = Connection.ToString(dt.Rows[0]["Title"]);
                result.SupplierId               = Connection.ToLong(dt.Rows[0]["SupplierID"]);
                result.InvoiceNumber            = Connection.ToString(dt.Rows[0]["InvoiceNumber"]);
                result.InvoiceDate              = Connection.ToDate(dt.Rows[0]["InvoiceDate"]);
                result.ServiceTaxRegNumber      = Connection.ToString(dt.Rows[0]["ServiceTaxRegNumber"]);
                result.PAN_Number               = Connection.ToString(dt.Rows[0]["PAN"]);
                result.BaseAmount               = Connection.ToDecimal(dt.Rows[0]["BaseAmount"]);
                result.LuxuryTax                = Connection.ToDecimal(dt.Rows[0]["LuxuryTax"]);
                result.ServiceTax               = Connection.ToDecimal(dt.Rows[0]["ServiceTax"]);
                result.TotalInvoiceValue        = Connection.ToDecimal(dt.Rows[0]["TotalInvoiceValue"]);
                result.EntryDate                = Connection.ToDate(dt.Rows[0]["EntryDate"]);
                result.txtTotalAdjustmentResult = Connection.ToDecimal(dt.Rows[0]["TotalAdjustment"]);
                result.PropertyEmailAddresss    = Connection.ToString(dt.Rows[0]["PropertyEmailAddress"]);
                result.PropertyType             = Connection.ToString(dt.Rows[0]["PropertyType"]);
                result.TaxType                 = Connection.ToInteger(dt.Rows[0]["TaxType"]);
                result.IsSupInvoicedone        = Connection.ToBoolean(dt.Rows[0]["IsSupInvoicedone"]);
                result.BookingRefNumber        = Connection.ToString(dt.Rows[0]["BookingReferenceIDNo"]);
                result.CheckedBookingRefNumber = Connection.ToString(dt.Rows[0]["CheckedBookingReferenceIDNo"]);
            }
            return(result);
        }
        public long Save(CLayer.SupplierInvoice data)
        {
            List <DataPlug.Parameter> param = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pSupplierInvoiceID", DataPlug.DataType._BigInt, data.SupplierInvoiceID));
            param.Add(Connection.GetParameter("pPropertyID", DataPlug.DataType._Int, data.PropertyId));
            param.Add(Connection.GetParameter("pSupplierID", DataPlug.DataType._Int, data.SupplierId));
            param.Add(Connection.GetParameter("pInvoiceNumber", DataPlug.DataType._Text, data.InvoiceNumber));
            param.Add(Connection.GetParameter("pInvoiceDate", DataPlug.DataType._DateTime, data.InvoiceDate));
            param.Add(Connection.GetParameter("pServiceTaxRegNumber", DataPlug.DataType._Text, data.ServiceTaxRegNumber));
            param.Add(Connection.GetParameter("pPAN", DataPlug.DataType._Text, data.PAN_Number));
            param.Add(Connection.GetParameter("pBaseAmount", DataPlug.DataType._Decimal, data.BaseAmount));
            param.Add(Connection.GetParameter("pLuxuryTax", DataPlug.DataType._Decimal, data.LuxuryTax));
            param.Add(Connection.GetParameter("pServiceTax", DataPlug.DataType._Decimal, data.ServiceTax));
            param.Add(Connection.GetParameter("pTotalInvoiceValue", DataPlug.DataType._Decimal, data.TotalInvoiceValue));
            param.Add(Connection.GetParameter("pEntryDate", DataPlug.DataType._DateTime, data.EntryDate));
            param.Add(Connection.GetParameter("ptxtTotalAdjustmentResult", DataPlug.DataType._Decimal, data.txtTotalAdjustmentResult));
            param.Add(Connection.GetParameter("pPropertyEmailAddresss", DataPlug.DataType._Text, data.PropertyEmailAddresss));
            param.Add(Connection.GetParameter("pPropertyType", DataPlug.DataType._Text, data.PropertyType));
            param.Add(Connection.GetParameter("pTaxType", DataPlug.DataType._Text, data.TaxType));
            param.Add(Connection.GetParameter("pIsSupInvoicedone", DataPlug.DataType._Bool, data.IsSupInvoicedone));
            object result = Connection.ExecuteQueryScalar("SupplierInvoice_save", param);

            return(Connection.ToInteger(result));
        }
        public ActionResult Details(long ID = 0, bool isFromList = false)
        {
            Models.SuppierInvoiceModel model = new Models.SuppierInvoiceModel();
            int TotalRows_Booking;

            try
            {
                if (ID > 0)
                {
                    CLayer.SupplierInvoice data = new CLayer.SupplierInvoice();
                    data = BLayer.SupplierInvoice.getGetSupplierInvoicedetails(ID);
                    model.SupplierInvoiceID        = data.SupplierInvoiceID;
                    model.PropertyId               = data.PropertyId;
                    model.SupplierId               = data.SupplierId;
                    model.PropertyName             = data.Property_Name;
                    model.InvoiceNumber            = data.InvoiceNumber;
                    model.InvoiceDate              = data.InvoiceDate == null ? "" : Convert.ToString(data.InvoiceDate.ToString("dd/MM/yyyy"));
                    model.ServiceTaxRegNumber      = data.ServiceTaxRegNumber;
                    model.PAN_Number               = data.PAN_Number;
                    model.BaseAmount               = data.BaseAmount;
                    model.LuxuryTax                = data.LuxuryTax;
                    model.ServiceTax               = data.ServiceTax;
                    model.TotalInvoiceValue        = data.TotalInvoiceValue;
                    model.EntryDate                = data.EntryDate == null ? "" : Convert.ToString(data.EntryDate.ToString("dd/MM/yyyy"));
                    model.txtTotalAdjustmentResult = data.txtTotalAdjustmentResult;
                    model.isFromList               = isFromList;
                    model.PropertyEmailAddresss    = data.PropertyEmailAddresss;
                    model.PropertyType             = data.PropertyType;
                    model.TaxType          = data.TaxType;
                    model.IsSupInvoicedone = data.IsSupInvoicedone;

                    model.BookingRefIDs        = data.BookingRefNumber;
                    model.checkedBookingRefIDs = data.CheckedBookingRefNumber;
                    if (data.PropertyId > 0 && ID > 0)
                    {
                        model.BookingList         = BLayer.SupplierInvoice.SupplierInvoiceBookingList(data.PropertyId, ID, "", data.PropertyEmailAddresss, data.PropertyType, 0, LIMIT_Booking, 2, out TotalRows_Booking);
                        model.currentPage_Booking = 1;
                        model.Limit_Booking       = LIMIT_Booking;
                        model.TotalRows_Booking   = TotalRows_Booking;
                        //model.savedBookingList = null;
                        model.savedBookingList = BLayer.SupplierInvoice.SupplierInvoiceSavedBookingList(data.PropertyId, ID, "", data.PropertyEmailAddresss, data.PropertyType);
                    }
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(View("~/Areas/Admin/Views/SupplierInvoiceDetails/Index.cshtml", model));
        }
        public List <CLayer.SupplierInvoice> getSupplierInvoiceList_Report(long Start, long Limit, DateTime?fromDT, DateTime?toDT)
        {
            fromDT = fromDT == DateTime.MinValue ? null : fromDT;
            toDT   = toDT == DateTime.MinValue ? null : toDT;
            List <CLayer.SupplierInvoice> result = new List <CLayer.SupplierInvoice>();
            List <DataPlug.Parameter>     param  = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pfromDT", DataPlug.DataType._Date, fromDT));
            param.Add(Connection.GetParameter("ptoDT", DataPlug.DataType._Date, toDT));
            param.Add(Connection.GetParameter("pStart", DataPlug.DataType._BigInt, Start));
            param.Add(Connection.GetParameter("pLimit", DataPlug.DataType._BigInt, Limit));
            DataSet ds = Connection.GetDataSet("getGetSupplierInvoiceList_Report", param);

            CLayer.SupplierInvoice res = null;
            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[1].Rows)
                {
                    res = new CLayer.SupplierInvoice();
                    res.SupplierInvoiceID = Connection.ToLong(dr["SupplierInvoiceID"]);
                    res.PropertyId        = Connection.ToLong(dr["PropertyID"]);
                    res.Property_Name     = Connection.ToString(dr["Title"]);
                    res.SupplierId        = Connection.ToLong(dr["SupplierID"]);
                    res.SupplierName      = Connection.ToString(dr["SupplierName"]);
                    res.City                = Connection.ToString(dr["City"]);
                    res.InvoiceNumber       = Connection.ToString(dr["InvoiceNumber"]);
                    res.InvoiceDate         = Connection.ToDate(dr["InvoiceDate"]);
                    res.ServiceTaxRegNumber = Connection.ToString(dr["ServiceTaxRegNumber"]);
                    res.PAN_Number          = Connection.ToString(dr["PAN"]);
                    res.BaseAmount          = Connection.ToDecimal(dr["BaseAmount"]);
                    res.LuxuryTax           = Connection.ToDecimal(dr["LuxuryTax"]);
                    res.ServiceTax          = Connection.ToDecimal(dr["ServiceTax"]);
                    res.TotalInvoiceValue   = Connection.ToDecimal(dr["TotalInvoiceValue"]);
                    res.EntryDate           = Connection.ToDate(dr["EntryDate"]);

                    res.SupplierInvoiceBooking_ID = Connection.ToLong(dr["SupplierInvoiceBooking_ID"]);
                    res.BookingRefNumber          = Connection.ToString(dr["BookingRefNumber"]);
                    res.CheckIn_date    = Connection.ToDate(dr["CheckIn_date"]);
                    res.CheckOut_date   = Connection.ToDate(dr["CheckOut_date"]);
                    res.BookinCreatedDT = Connection.ToDate(dr["BookinCreatedDT"]);

                    res.TotalRows = Connection.ToLong(ds.Tables[0].Rows[0]["NumberOfRows"]);

                    result.Add(res);
                }
            }
            return(result);
        }
        public List <CLayer.SupplierInvoice> getSupplierInvoiceList(string searchText, int searchType, int Start, int Limit, int TaxType, int Status)
        {
            List <CLayer.SupplierInvoice> result = new List <CLayer.SupplierInvoice>();
            List <DataPlug.Parameter>     param  = new List <DataPlug.Parameter>();

            param.Add(Connection.GetParameter("pSearchText", DataPlug.DataType._Text, searchText));
            param.Add(Connection.GetParameter("pSearchType", DataPlug.DataType._Int, searchType));
            param.Add(Connection.GetParameter("pStart", DataPlug.DataType._Int, Start));
            param.Add(Connection.GetParameter("pLimit", DataPlug.DataType._Int, Limit));
            param.Add(Connection.GetParameter("pTaxType", DataPlug.DataType._Int, TaxType));
            param.Add(Connection.GetParameter("pStatus", DataPlug.DataType._Int, Status));
            DataSet ds = Connection.GetDataSet("getGetSupplierInvoiceList_Pager", param);

            CLayer.SupplierInvoice res = null;
            if (ds.Tables[1].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[1].Rows)
                {
                    res = new CLayer.SupplierInvoice();
                    res.SupplierInvoiceID = Connection.ToLong(dr["SupplierInvoiceID"]);
                    res.PropertyId        = Connection.ToLong(dr["PropertyID"]);
                    res.Property_Name     = Connection.ToString(dr["Title"]);
                    res.SupplierId        = Connection.ToLong(dr["SupplierID"]);
                    res.SupplierName      = Connection.ToString(dr["SupplierName"]);
                    res.City                = Connection.ToString(dr["City"]);
                    res.InvoiceNumber       = Connection.ToString(dr["InvoiceNumber"]);
                    res.InvoiceDate         = Connection.ToDate(dr["InvoiceDate"]);
                    res.ServiceTaxRegNumber = Connection.ToString(dr["ServiceTaxRegNumber"]);
                    res.PAN_Number          = Connection.ToString(dr["PAN"]);
                    res.BaseAmount          = Connection.ToDecimal(dr["BaseAmount"]);
                    res.LuxuryTax           = Connection.ToDecimal(dr["LuxuryTax"]);
                    res.ServiceTax          = Connection.ToDecimal(dr["ServiceTax"]);
                    res.TotalInvoiceValue   = Connection.ToDecimal(dr["TotalInvoiceValue"]);
                    res.EntryDate           = Connection.ToDate(dr["EntryDate"]);
                    res.TaxType             = Connection.ToInteger(dr["TaxType"]);
                    res.TotalRows           = Connection.ToLong(ds.Tables[0].Rows[0]["NumberOfRows"]);
                    result.Add(res);
                }
            }
            return(result);
        }
 public static long Save(CLayer.SupplierInvoice data)
 {
     DataLayer.SupplierInvoice acc = new DataLayer.SupplierInvoice();
     return(acc.Save(data));
 }
        public ActionResult saveSupplierInvoiceDetails(Models.SuppierInvoiceModel model)
        {
            try
            {
                CLayer.SupplierInvoice data = new CLayer.SupplierInvoice();
                data.SupplierInvoiceID        = model.SupplierInvoiceID;
                data.PropertyId               = model.PropertyId;
                data.SupplierId               = model.SupplierId;
                data.InvoiceNumber            = model.InvoiceNumber;
                data.InvoiceDate              = model.InvoiceDate == null ? DateTime.Now : DateTime.ParseExact(model.InvoiceDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                data.ServiceTaxRegNumber      = model.ServiceTaxRegNumber;
                data.PAN_Number               = model.PAN_Number;
                data.BaseAmount               = model.BaseAmount;
                data.LuxuryTax                = model.LuxuryTax;
                data.ServiceTax               = model.ServiceTax;
                data.TotalInvoiceValue        = model.TotalInvoiceValue;
                data.EntryDate                = model.EntryDate == null ? DateTime.Now : DateTime.ParseExact(model.EntryDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                data.txtTotalAdjustmentResult = model.txtTotalAdjustmentResult;
                data.PropertyEmailAddresss    = model.PropertyEmailAddresss;
                data.PropertyType             = model.PropertyType;
                data.TaxType          = model.TaxType;
                data.IsSupInvoicedone = model.IsSupInvoicedone;
                long ID = BLayer.SupplierInvoice.Save(data);
                data.SupplierInvoiceID = ID;
                if (ID > 0)
                {
                    if (model.BookingRefIDsWithValue != null)
                    {
                        if (model.BookingRefIDsWithValue.Length > 0)
                        {
                            List <CLayer.OfflineBooking> lis = new List <CLayer.OfflineBooking>();

                            foreach (string num in model.BookingRefIDsWithValue.Split(',').ToList <string>())
                            {
                                string[] numwtvle = num.Split('#');
                                string   BkgNum   = numwtvle[0];

                                bool   isChecked = false;
                                string dupe_num  = BkgNum == null ? "" : BkgNum;
                                if (dupe_num.Trim() != "")
                                {
                                    if (model.checkedBookingRefIDs != null)
                                    {
                                        foreach (string chkNum in model.checkedBookingRefIDs.Split(',').ToList <string>())
                                        {
                                            string checkedNum = chkNum == null ? "" : chkNum;
                                            if (checkedNum != "")
                                            {
                                                if (dupe_num == checkedNum)
                                                {
                                                    isChecked = true;
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        isChecked = false;
                                    }

                                    CLayer.OfflineBooking rs = new CLayer.OfflineBooking();
                                    rs.ConfirmationNumber = BkgNum;
                                    rs.SupplierInvoiceID  = ID;
                                    rs.isOpen             = isChecked;

                                    decimal SupInvoiceValueBRef = 0;
                                    if (numwtvle[1] == null)
                                    {
                                        SupInvoiceValueBRef = 0;
                                    }
                                    else
                                    {
                                        SupInvoiceValueBRef = Convert.ToDecimal(numwtvle[1]);
                                    }

                                    decimal PaidValueBRef = 0;
                                    if (numwtvle[2] == null)
                                    {
                                        PaidValueBRef = 0;
                                    }
                                    else
                                    {
                                        PaidValueBRef = Convert.ToDecimal(numwtvle[2]);
                                    }

                                    rs.SupInvoiceValueBRef = SupInvoiceValueBRef;
                                    rs.PaidValueBRef       = PaidValueBRef;
                                    lis.Add(rs);
                                }
                            }
                            if (lis != null)
                            {
                                if (lis.Count() > 0)
                                {
                                    BLayer.SupplierInvoice.saveSupplierInvoiceBooking(lis);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            if (model.TaxType == (int)CLayer.SupplierInvoice.TaxTypes.ServiceTax)
            {
                if (model.isFromList)
                {
                    return(RedirectToAction("getSupplierInvoiceList"));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                if (model.isFromList)
                {
                    return(RedirectToAction("getSupplierInvoiceListForgst"));
                }
                else
                {
                    return(RedirectToAction("GSTIndex"));
                }
            }
        }