private string InsertQuotationData(EmailMessageInfo objMailModel, List <CargoRatesModel> objCRList)
        {
            string result = "";
            ACRF_QuotationModel objQuotModel = new ACRF_QuotationModel();
            List <ACRF_QuotationDetailsModel> objQuotDetList = new List <ACRF_QuotationDetailsModel>();

            objQuotModel.ClientMail      = objMailModel.ToEmailAddress;
            objQuotModel.FromMail        = objMailModel.FromEmailAddress;
            objQuotModel.MailSubject     = objMailModel.EmailSubject;
            objQuotModel.QuotationStatus = QuotationType.InProgress;
            objQuotModel.VendorId        = objMailModel.VendorId;
            objQuotModel.CreatedBy       = objMailModel.FromEmailAddress;

            foreach (var data in objCRList)
            {
                if (data.IsSelect == true)
                {
                    ACRF_QuotationDetailsModel tempobj = new ACRF_QuotationDetailsModel();
                    tempobj.AirlineId        = data.AirlineId;
                    tempobj.AMS              = data.AMS;
                    tempobj.Ctc              = data.Ctc;
                    tempobj.DAirportName     = data.DAirportName;
                    tempobj.DCityCode        = data.DCityCode;
                    tempobj.DCountryCode     = data.DCountryCode;
                    tempobj.DisplayRateName1 = objMailModel.DisplayRateName1;
                    tempobj.DisplayRateName2 = objMailModel.DisplayRateName2;
                    tempobj.DisplayRateName3 = objMailModel.DisplayRateName3;
                    tempobj.Freight          = data.Freight;
                    tempobj.FSC              = data.FSC;
                    tempobj.Id           = data.Id;
                    tempobj.IsRate1      = objMailModel.IsRate1;
                    tempobj.IsRate2      = objMailModel.IsRate2;
                    tempobj.IsRate3      = objMailModel.IsRate3;
                    tempobj.Mcc          = data.Mcc;
                    tempobj.OAirportName = data.OAirportName;
                    tempobj.OCityCode    = data.OCityCode;
                    tempobj.OCountryCode = data.OCountryCode;
                    tempobj.Rate         = data.Rate;
                    tempobj.Rate1        = data.Rate1;
                    tempobj.Rate2        = data.Rate2;
                    tempobj.Rate3        = data.Rate3;
                    tempobj.Slab1        = data.Slab1;
                    tempobj.TariffModeId = data.TariffModeId;
                    tempobj.TotalCost    = data.TotalCost;
                    tempobj.WSC          = data.WSC;
                    tempobj.Xray         = data.Xray;

                    objQuotDetList.Add(tempobj);
                }
            }
            objQuotModel.ACRF_QuotationDetailsModelList = objQuotDetList;

            result = objQuotVM.CreateQuotation(objQuotModel);
            return(result);
        }
예제 #2
0
        public ACRF_QuotationModel GetOneQuotation(int QuotationId)
        {
            ACRF_QuotationModel objModel = new ACRF_QuotationModel();
            List <ACRF_QuotationDetailsModel> objList = new List <ACRF_QuotationDetailsModel>();

            try
            {
                string sqlstr = "select QuotationId,VendorId,FromMail,ClientMail,Isnull(CC,'') as CC, Isnull(BCC,'') as BCC,"
                                + " MailSubject,QuotationStatus,CreatedOn,CreatedBy,Isnull(UpdatedOn,'') as UpdatedOn, "
                                + " Isnull(UpdatedBy,'') as UpdatedBy from ACRF_Quotation where QuotationId=@QuotationId";

                var connection = gConnection.Connection();
                connection.Open();
                SqlCommand cmd = new SqlCommand(sqlstr, connection);
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@QuotationId", QuotationId);
                SqlDataReader sdr = cmd.ExecuteReader();
                while (sdr.Read())
                {
                    objModel.QuotationId     = Convert.ToInt32(sdr["QuotationId"].ToString());
                    objModel.VendorId        = Convert.ToInt32(sdr["VendorId"].ToString());
                    objModel.FromMail        = sdr["FromMail"].ToString();
                    objModel.ClientMail      = sdr["ClientMail"].ToString();
                    objModel.CC              = sdr["CC"].ToString();
                    objModel.BCC             = sdr["BCC"].ToString();
                    objModel.MailSubject     = sdr["MailSubject"].ToString();
                    objModel.QuotationStatus = sdr["QuotationStatus"].ToString();
                    objModel.CreatedOn       = Convert.ToDateTime(sdr["CreatedOn"].ToString());
                    objModel.CreatedBy       = sdr["CreatedBy"].ToString();
                    objModel.UpdatedOn       = Convert.ToDateTime(sdr["UpdatedOn"].ToString());
                    objModel.UpdatedBy       = sdr["UpdatedBy"].ToString();
                }
                sdr.Close();


                sqlstr = "select Id,QuotationId,AirlineId,TariffModeId,OCountryCode,Isnull(OCityCode,'') as OCityCode, Isnull(OAirportName,'') as OAirportName,"
                         + " isnull(DCountryCode,'') as DCountryCode, isnull(DCityCode,'') as DCityCode, isnull(DAirportName,'') as DAirportName, "
                         + " isnull(Slab1,0) as Slab1, isnull(Rate,0) as Rate, isnull(Freight,0) as Freight, isnull(FSC,0) as FSC, "
                         + " isnull(WSC,0) as WSC, isnull(Xray,0) as Xray, isnull(Mcc,0) as Mcc, isnull(Ctc,0) as Ctc, isnull(AMS,0) as AMS, "
                         + " isnull(TotalCost,0) as TotalCost, isnull(IsRate1,'') as IsRate1, isnull(IsRate2,'') as IsRate2, isnull(IsRate3,'') as IsRate3, "
                         + " isnull(Rate1,0) as Rate1, isnull(Rate2,0) as Rate2, isnull(Rate3,0) as Rate3, isnull(DisplayRateName1,'') as DisplayRateName1, "
                         + " isnull(DisplayRateName2,'') as DisplayRateName2, isnull(DisplayRateName3,'') as DisplayRateName3, isnull(CreatedBy,'') as CreatedBy, "
                         + " isnull((Select top 1 AirlineName From ACRF_Airlines D where D.Id=Q.AirlineId),'') as Airline, "
                         + " isnull((Select top 1 AirlinePhoto From ACRF_Airlines D where D.Id=Q.AirlineId),'') as AirlinePhoto, "
                         + " isnull((Select top 1 CityName From ACRF_DestinationMaster D where D.CityCode= Q.DCityCode),'') as DCityName, "
                         + " isnull((Select top 1 TariffMode From ACRF_TariffMode D where D.Id= Q.TariffModeId),'') as TariffMode, "
                         + " isnull(CreatedOn,'') as CreatedOn from ACRF_QuotationDetails Q where QuotationId=@QuotationId";
                cmd.CommandText = sqlstr;
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@QuotationId", QuotationId);
                sdr = cmd.ExecuteReader();
                while (sdr.Read())
                {
                    ACRF_QuotationDetailsModel tempobj = new ACRF_QuotationDetailsModel();
                    tempobj.Id               = Convert.ToInt32(sdr["Id"].ToString());
                    tempobj.QuotationId      = Convert.ToInt32(sdr["QuotationId"].ToString());
                    tempobj.AirlineId        = Convert.ToInt32(sdr["AirlineId"].ToString());
                    tempobj.TariffModeId     = Convert.ToInt32(sdr["TariffModeId"].ToString());
                    tempobj.OCountryCode     = sdr["OCountryCode"].ToString();
                    tempobj.OCityCode        = sdr["OCityCode"].ToString();
                    tempobj.OAirportName     = sdr["OAirportName"].ToString();
                    tempobj.DCountryCode     = sdr["DCountryCode"].ToString();
                    tempobj.DCityCode        = sdr["DCityCode"].ToString();
                    tempobj.DAirportName     = sdr["DAirportName"].ToString();
                    tempobj.Slab1            = Convert.ToDecimal(sdr["Slab1"].ToString());
                    tempobj.Rate             = Convert.ToDecimal(sdr["Rate"].ToString());
                    tempobj.Freight          = Convert.ToDecimal(sdr["Freight"].ToString());
                    tempobj.FSC              = Convert.ToDecimal(sdr["FSC"].ToString());
                    tempobj.WSC              = Convert.ToDecimal(sdr["WSC"].ToString());
                    tempobj.Xray             = Convert.ToDecimal(sdr["Xray"].ToString());
                    tempobj.Mcc              = Convert.ToDecimal(sdr["Mcc"].ToString());
                    tempobj.Ctc              = Convert.ToDecimal(sdr["Ctc"].ToString());
                    tempobj.AMS              = Convert.ToDecimal(sdr["AMS"].ToString());
                    tempobj.TotalCost        = Convert.ToDecimal(sdr["TotalCost"].ToString());
                    tempobj.IsRate1          = Convert.ToBoolean(sdr["IsRate1"].ToString());
                    tempobj.IsRate2          = Convert.ToBoolean(sdr["IsRate2"].ToString());
                    tempobj.IsRate3          = Convert.ToBoolean(sdr["IsRate3"].ToString());
                    tempobj.Rate1            = Convert.ToDecimal(sdr["Rate1"].ToString());
                    tempobj.Rate2            = Convert.ToDecimal(sdr["Rate2"].ToString());
                    tempobj.Rate3            = Convert.ToDecimal(sdr["Rate3"].ToString());
                    tempobj.DisplayRateName1 = sdr["DisplayRateName1"].ToString();
                    tempobj.DisplayRateName2 = sdr["DisplayRateName2"].ToString();
                    tempobj.DisplayRateName3 = sdr["DisplayRateName3"].ToString();
                    tempobj.CreatedOn        = Convert.ToDateTime(sdr["CreatedOn"].ToString());
                    tempobj.CreatedBy        = sdr["CreatedBy"].ToString();

                    tempobj.Airline = sdr["Airline"].ToString();

                    if (sdr["AirlinePhoto"].ToString() == "")
                    {
                        tempobj.AirlinePhoto     = "";
                        tempobj.AirlineDemoPhoto = tempobj.Airline[0].ToString();
                    }
                    else
                    {
                        tempobj.AirlinePhoto = GlobalFunction.GetAPIUrl() + sdr["AirlinePhoto"].ToString();
                    }

                    objModel.DCityName  = sdr["DCityName"].ToString();
                    objModel.TariffMode = sdr["TariffMode"].ToString();
                    objModel.Origin     = sdr["OAirportName"].ToString();

                    objList.Add(tempobj);
                }

                connection.Close();
                objModel.ACRF_QuotationDetailsModelList = objList;
            }
            catch (Exception ex)
            {
                ErrorHandlerClass.LogError(ex);
            }
            return(objModel);
        }