Exemple #1
0
        public Int32 UpdateStatus(int intLorryIdno, bool Status, Int32 empIdno)
        {
            int value = 0;

            try
            {
                using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
                {
                    LorryMast objLorryMast = (from mast in db.LorryMasts
                                              where mast.Lorry_Idno == intLorryIdno
                                              select mast).FirstOrDefault();
                    if (objLorryMast != null)
                    {
                        objLorryMast.Status        = Status;
                        objLorryMast.Emp_Idno      = empIdno;
                        objLorryMast.Date_Modified = System.DateTime.Now;
                        db.SaveChanges();
                        value = 1;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(value);
        }
Exemple #2
0
        /// <summary>
        /// Delete record from LorryMast
        /// </summary>
        /// <param name="intLorryIdno"></param>
        /// <returns></returns>
        public int Delete(int intLorryIdno)
        {
            int intValue = 0;

            try
            {
                using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
                {
                    LorryMast objLorryMast = (from mast in db.LorryMasts
                                              where mast.Lorry_Idno == intLorryIdno
                                              select mast).FirstOrDefault();
                    if (objLorryMast != null)
                    {
                        db.LorryMasts.DeleteObject(objLorryMast);
                        db.SaveChanges();
                        intValue = 1;
                    }
                }
            }
            catch (Exception Ex)
            {
                if (Convert.ToBoolean(Ex.InnerException.Message.Contains("The DELETE statement conflicted with the REFERENCE constraint")) == true)
                {
                    intValue = -1;
                }
            }
            return(intValue);
        }
Exemple #3
0
 /// <summary>
 /// To check record existence in LorryMast
 /// </summary>
 /// <param name="strOwnerrName"></param>
 /// <param name="intLorryIdno"></param>
 /// <returns></returns>
 public bool IsExists(string strOwnerrName, Int64 intLorryIdno)
 {
     using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
     {
         LorryMast objLorryMast = new LorryMast();
         if (intLorryIdno <= 0)
         {
             objLorryMast = (from mast in db.LorryMasts
                             where mast.Lorry_No == strOwnerrName && mast.Status == true
                             select mast).FirstOrDefault();
         }
         else if (intLorryIdno > 0)
         {
             objLorryMast = (from mast in db.LorryMasts
                             where mast.Lorry_No == strOwnerrName &&
                             mast.Lorry_Idno != intLorryIdno
                             select mast).FirstOrDefault();
         }
         if (objLorryMast != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
 public LorryMast selectOwnerName(Int32 LorryIdno)
 {
     using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
     {
         LorryMast lst = ((from DR in db.LorryMasts where DR.Lorry_Idno == LorryIdno select DR).FirstOrDefault());
         return(lst);
     }
 }
Exemple #5
0
        public Int64 InsertPartyChangeDetails(DataTable dt)
        {
            Int64 intValue = 0;

            try
            {
                using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            tblLorryPrtyDetl objNewPartyInsert = new tblLorryPrtyDetl();
                            if (IsPartyExists(Convert.ToInt64(dt.Rows[i]["LorryIdNo"]), Convert.ToInt64(dt.Rows[i]["AcntIdno"]), Convert.ToDateTime(dt.Rows[i]["ValidFrom"])) == true)
                            {
                                intValue = -1;
                            }
                            else
                            {
                                objNewPartyInsert.Lorry_Idno = Convert.ToInt64(dt.Rows[i]["LorryIdNo"]);
                                objNewPartyInsert.Acnt_Idno  = Convert.ToInt64(dt.Rows[i]["AcntIdno"]);
                                objNewPartyInsert.Valid_From = Convert.ToDateTime(dt.Rows[i]["ValidFrom"]);
                                db.tblLorryPrtyDetls.AddObject(objNewPartyInsert);
                                db.SaveChanges();

                                LorryMast objLorryMast = new LorryMast();
                                Int64     LorryIdno    = Convert.ToInt64(dt.Rows[i]["LorryIdNo"]);
                                objLorryMast = (from mast in db.LorryMasts
                                                where mast.Lorry_Idno == LorryIdno
                                                select mast).FirstOrDefault();
                                if (objLorryMast != null)
                                {
                                    objLorryMast.Prty_Idno = Convert.ToInt64(dt.Rows[i]["AcntIdno"]);
                                    db.SaveChanges();
                                }
                            }
                        }
                        intValue = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                //ApplicationFunction.ErrorLog(ex.ToString());
            }
            return(intValue);
        }
Exemple #6
0
        /// <summary>
        /// Update records in LorryMast
        /// </summary>
        /// <param name="strNarrName"></param>
        /// <param name="strNarrDesc"></param>
        /// <param name="bStatus"></param>
        /// <param name="intNarrIdno"></param>
        /// <returns></returns>
        public Int64 UpdateLorryMast(string strLorryMake, string strLorryMakeYar, string strOwnerName, Int32 LorryType, Int64 PartyName, string strChasisNo, string strNumberOfTyres, string strEngineNo, string strLorryNo, string strPanNo, bool bStatus, bool bcommsn, Int64 intType, Int64 intLorryIdno, int pantypeIdno, DateTime?FitnessDate, DateTime?RCDate, DateTime?NatPermitDate, DateTime?AuthPermitDate, string TrollyLength, string TrollyHeight, string TrollyWeight, string TrollyTyerNo, string InsNo, string InsCompName, DateTime?InsValidDate, string FinName, string FinAmount, string FinEMIAmount, string FinTotalInstall, DateTime?FinPeriodFrom, DateTime?FinPeriodTo, bool CalOnDF, Int64 DriverIdno, Double InsurAmount, int FITwarn, int INSwarn, int RCwarn, int NatWarn, int AuthWarn, Int32 empIdno, bool LowRate, string strOwnerAdd, string strOwnerMobile)
        {
            Int64 intValue = 0;

            //Int32 intLorryIdno = 1;
            try
            {
                using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
                {
                    LorryMast objLorryMast = (from mast in db.LorryMasts
                                              where mast.Lorry_Idno == intLorryIdno
                                              select mast).FirstOrDefault();
                    if (objLorryMast != null)
                    {
                        objLorryMast.Lorry_Make    = strLorryMake;
                        objLorryMast.Lorry_Year    = strLorryMakeYar;
                        objLorryMast.Owner_Name    = strOwnerName;
                        objLorryMast.Owner_Address = strOwnerAdd;
                        objLorryMast.Owner_Mobile  = strOwnerMobile;
                        objLorryMast.Lorry_Type    = LorryType;
                        objLorryMast.Status        = bStatus;
                        objLorryMast.chk_ComsnCal  = bcommsn;
                        objLorryMast.Type          = intType;
                        objLorryMast.Ins_Amount    = InsurAmount;
                        objLorryMast.Emp_Idno      = empIdno;

                        objLorryMast.Prty_Idno   = PartyName;
                        objLorryMast.Chassis_no  = strChasisNo;
                        objLorryMast.Tyres_No    = strNumberOfTyres;
                        objLorryMast.Eng_No      = strEngineNo;
                        objLorryMast.Lorry_No    = strLorryNo;
                        objLorryMast.Pan_No      = strPanNo;
                        objLorryMast.PANTyp_Idno = pantypeIdno;

                        objLorryMast.Fitness_Date     = FitnessDate;
                        objLorryMast.RC_Date          = RCDate;
                        objLorryMast.Nat_Permit_Date  = NatPermitDate;
                        objLorryMast.Auth_Permit_Date = AuthPermitDate;
                        objLorryMast.Trolly_Length    = TrollyLength;
                        objLorryMast.Trolly_Height    = TrollyHeight;
                        objLorryMast.Trolly_Weight    = TrollyWeight;
                        objLorryMast.Trolly_TyerNo    = TrollyTyerNo;

                        objLorryMast.Ins_No            = InsNo;
                        objLorryMast.Ins_Comp_Name     = InsCompName;
                        objLorryMast.Ins_Valid_Date    = InsValidDate;
                        objLorryMast.Fin_Name          = FinName;
                        objLorryMast.Fin_Amount        = FinAmount;
                        objLorryMast.Fin_EMI_Amount    = FinEMIAmount;
                        objLorryMast.Fin_Total_Install = FinTotalInstall;
                        objLorryMast.Fin_Period_From   = FinPeriodFrom;
                        objLorryMast.Fin_Period_To     = FinPeriodTo;
                        objLorryMast.Driver_Idno       = DriverIdno;

                        objLorryMast.FITwarn  = FITwarn;
                        objLorryMast.INSwarn  = INSwarn;
                        objLorryMast.RCwarn   = RCwarn;
                        objLorryMast.NatWarn  = NatWarn;
                        objLorryMast.AuthWarn = AuthWarn;

                        objLorryMast.CalOn_DF    = CalOnDF;
                        objLorryMast.LowRateWise = LowRate;
                        objLorryMast.Date_Added  = System.DateTime.Now;
                        if (IsExists(strLorryNo, intLorryIdno) == true)
                        {
                            intValue = -1;
                        }
                        else
                        {
                            db.SaveChanges();
                            intValue = intLorryIdno;
                        }
                        if (intValue > 0)
                        {
                            tblLorryPrtyDetl lPrty = db.tblLorryPrtyDetls.Where(X => X.Lorry_Idno == intValue && X.Acnt_Idno == PartyName).FirstOrDefault();
                            if (lPrty != null)
                            {
                                //string strSQL = @"select Convert(nvarchar(11),convert(datetime,StartDate,105),105) AS SDate  from tblFinYear  order by Fin_Idno desc";
                                //DataSet ds = SqlHelper.ExecuteDataset(MultipleDBDAL.strDynamicConString(), CommandType.Text, strSQL);
                                //string strNewDate = ds.Tables[0].Rows[0]["SDate"].ToString();
                                var strNewDate = db.tblFinYears.Select(o => o.StartDate).Max();
                                //        lPrty.Lorry_Idno = intValue;
                                //        lPrty.Acnt_Idno = PartyName;
                                //lPrty.Valid_From = Convert.ToDateTime(strNewDate);
                                db.SaveChanges();
                            }
                        }
                        IList <LorryMast> obj = db.LorryMasts.Where(lm => lm.Pan_No == objLorryMast.Pan_No).ToList();
                        if (obj.Count > 0)
                        {
                            foreach (LorryMast rw in obj)
                            {
                                rw.CalOn_DF    = objLorryMast.CalOn_DF;
                                rw.LowRateWise = objLorryMast.LowRateWise;
                                db.SaveChanges();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //ApplicationFunction.ErrorLog(ex.ToString());
            }
            return(intValue);
        }