예제 #1
0
        /// <summary>
        /// Close Appointment Used for Visitor GatePass
        /// </summary>
        /// <param name="objVisitorGP"></param>
        public static void CloseAppointment(VisitorGatePass objVisitorGP)
        {
            int result = 0;

            using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString()))
            {
                using (SqlCommand objCmd = new SqlCommand())
                {
                    try
                    {
                        objCmd.Connection  = Conn;
                        objCmd.CommandType = CommandType.Text;
                        objCmd.CommandText = "UPDATE APPOINTMENTMASTER " +
                                             " SET APMTCLOSE = @value " +
                                             " WHERE APPOINTMENTNO = @AppointmentNo ";
                        objCmd.Parameters.AddWithValue("@value", true);
                        objCmd.Parameters.AddWithValue("@AppointmentNo", objVisitorGP.AppointmentNo);

                        if (Conn.State != ConnectionState.Open)
                        {
                            Conn.Open();
                        }
                        result = objCmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
예제 #2
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (lvwGPs.SelectedItems != null && lvwGPs.SelectedItems.Count != 0)
                {
                    if (!IsList)
                    {
                        if (objUIRights.DeleteRight)
                        {
                            DialogResult dr = new DialogResult();
                            dr = MessageBox.Show("Do You Really Want to Delete Record ?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                            if (dr == DialogResult.Yes)
                            {
                                VisitorGatePass objVisitorGP = new VisitorGatePass();
                                objVisitorGP = VisitorGatePassManager.GetItem(Convert.ToInt32(lvwGPs.SelectedItems[0].Name));
                                VisitorGatePassManager.Delete(objVisitorGP);
                                lvwGPs.Items.Remove(lvwGPs.SelectedItems[0]);
                            }
                        }
                        else
                        {
                            throw new Exception("Not Authorised.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #3
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (!IsList)
                {
                    if (objUIRights.AddRight)
                    {
                        VisitorGatePass  objVisitorGP;
                        frmVisitorGPProp objFrmProp;

                        objVisitorGP                  = new VisitorGatePass();
                        objFrmProp                    = new frmVisitorGPProp(objVisitorGP, currentUser);
                        objFrmProp.IsNew              = true;
                        objFrmProp.MdiParent          = this.MdiParent;
                        objFrmProp.Entry_DataChanged += new frmVisitorGPProp.VisitorGPUpdateHandler(Entry_DataChanged);
                        objFrmProp.Show();
                    }
                    else
                    {
                        throw new Exception("Not Authorised.");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #4
0
        /// <summary>
        /// Saves current Object Values into Database.
        /// </summary>
        /// <param name="objVisitorGP">Current VisitorGP Object.</param>
        /// <returns>Boolean value True if record is saved successfully
        /// otherwise returns 'False' indicating record is not saved.</returns>
        public static bool Save(VisitorGatePass objVisitorGP, User objCurUser)
        {
            bool flgSave;

            try
            {
                using (TransactionScope objTScope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    if (objVisitorGP.IsEdited || objVisitorGP.IsNew)
                    {
                        //if (IsGatePassExist(objVisitorGP))
                        //{
                        //    throw new Exception("GatePass Already Exists.");
                        //}
                        //else
                        //{
                        VisitorGatePassDAL.Save(objVisitorGP, objCurUser);
                        if (objVisitorGP.IsNew)
                        {
                            VisitorGatePassDAL.CloseAppointment(objVisitorGP);
                        }
                        //}
                    }
                    flgSave = true;
                    objTScope.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(flgSave);
        }
예제 #5
0
        /// <summary>
        /// Deletes Record from Database.
        /// </summary>
        /// <param name="objVisitorGP">Object containing all data values.</param>
        /// <returns>boolean value True if Record is deleted successfully
        /// otherwise returns False.</returns>
        public static bool Delete(VisitorGatePass objVisitorGP)
        {
            bool recDel;

            recDel = VisitorGatePassDAL.Delete(objVisitorGP.DBID);
            if (recDel)
            {
                VisitorGatePassDAL.ReOpenAppointment(objVisitorGP.AppointmentNo);
            }
            return(recDel);
        }
예제 #6
0
        /// <summary>
        /// This method Checks whether Current Dept already exists in Database or not.
        /// </summary>
        /// <param name="objVisitorGP">Object Containing New Data Values.</param>
        /// <returns>Boolean value True if Current Record already exists
        /// otherwise returns False indicating current Record Does not exist.</returns>
        public static bool IsGatePassExist(VisitorGatePass objVisitorGP)
        {
            bool IsRecExist = false;

            //using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString()))
            //{
            //    try
            //    {
            //        SqlCommand objCmd = Conn.CreateCommand();
            //        objCmd.CommandType = CommandType.Text;
            //        objCmd.CommandText = "SELECT DBID FROM VISITORGATEPASS " +
            //            " WHERE DEPTNAME = @mDeptName " +
            //            " AND DBID <> @dbID ";

            //        objCmd.Parameters.AddWithValue("@mDeptName", objVisitorGatePass.DeptName);
            //        objCmd.Parameters.AddWithValue("@dbID", objVisitorGatePass.DBID);

            //        if (Conn.State != ConnectionState.Open)
            //        {
            //            Conn.Open();
            //        }

            //        using (SqlDataReader objReader = objCmd.ExecuteReader())
            //        {
            //            if (objReader.HasRows)
            //            {
            //                while (objReader.Read())
            //                {
            //                    IsRecExist = true;
            //                }
            //            }
            //            else
            //            {
            //                IsRecExist = false;
            //            }
            //        }
            //    }
            //    catch (ApplicationException ex)
            //    {
            //        throw new Exception(ex.Message);
            //    }
            //}
            return(IsRecExist);
        }
예제 #7
0
        /// <summary>
        /// This method retrieves "VisitorGatePass" Record from Database.
        /// </summary>
        /// <param name="dbid">Unique ID value based on which Record will be fetched.</param>
        /// <returns>Object "VisitorGatePass" containing Data Values.</returns>
        public static VisitorGatePass GetItem(int dbid)
        {
            VisitorGatePass objVisitorGP = null;

            using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString()))
            {
                using (SqlCommand objCmd = new SqlCommand())
                {
                    try
                    {
                        objCmd.Connection  = Conn;
                        objCmd.CommandType = CommandType.Text;
                        objCmd.CommandText = "SELECT * FROM VISITORGATEPASS " +
                                             " WHERE DBID = @DBID";
                        objCmd.Parameters.AddWithValue("@DBID", dbid);

                        if (Conn.State != ConnectionState.Open)
                        {
                            Conn.Open();
                        }

                        SqlDataReader oReader = objCmd.ExecuteReader();
                        if (oReader.Read())
                        {
                            objVisitorGP       = FillDataRecord(oReader);
                            objVisitorGP.IsNew = false;
                        }
                        oReader.Close();
                        oReader.Dispose();
                    }
                    catch
                    {
                        throw;
                    }
                }
            }
            return(objVisitorGP);
        }
예제 #8
0
        /// <summary>
        /// This method Saves Record into Database.
        /// </summary>
        /// <param name="objDept">Object containing Data values to be saved.</param>
        /// <returns>Boolean value True if Record is saved successfully
        /// otherwise returns False indicating Record is not saved.</returns>
        public static bool Save(VisitorGatePass objVisitorGP, User objCurUser)
        {
            int result = 0;
            //string tmpStr = "";
            DateTime    dt             = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            UserCompany CurrentCompany = new UserCompany();

            using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString()))
            {
                string strSaveQry;
                if (objVisitorGP.IsNew)
                {
                    strSaveQry = "INSERT INTO VISITORGATEPASS(dbid, gatePassNo, gateDate, " +
                                 " visitorID, Name, address, contactNo, vehicleNo, depositedMaterial, " +
                                 " carryMaterial, NoOfPersons, company, empID, toMeet, purpose, " +
                                 " timeIn, timeOut, appointmentNo, empMobile, exPersons, " +
                                 " ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME, VIMAGE) " +
                                 " VALUES (@dbid, @gatePassNo, @gateDate, @visitorID, @visitorName, " +
                                 " @address, @contactNo, @vehicleNo, @depositMaterial, " +
                                 " @carryMaterial, @NoOfPerson, @companyName, @empID, @toMeet, @purpose, " +
                                 " @timeIn, @timeOut, @appointmentNo, @empMobile, @exPersons, " +
                                 " @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName, @VImage)";
                }
                else
                {
                    strSaveQry = "UPDATE VISITORGATEPASS " +
                                 " SET gatePassNo = @GatePassNo, gateDate = @GateDate, visitorID = @visitorID, " +
                                 " Name = @visitorName, address = @address, contactNo = @contactNo, " +
                                 " vehicleNo = @vehicleNo, depositedMaterial = @depositMaterial, " +
                                 " carryMaterial = @carryMaterial, NoOfPersons = @NoOfPerson, company = @companyName, " +
                                 " empID = @empID, toMeet = @toMeet, purpose = @purpose, timeIn = @timeIn, " +
                                 " timeOut = @timeOut, appointmentNo = @appointmentNo, " +
                                 " empMobile = @empMobile, exPersons = @exPersons " +
                                 " WHERE DBID = @dbId";
                }

                try
                {
                    SqlCommand objCmd = Conn.CreateCommand();
                    objCmd.CommandType = CommandType.Text;
                    objCmd.CommandText = strSaveQry;

                    objCmd.Parameters.AddWithValue("@gateDate", objVisitorGP.GateDate);
                    objCmd.Parameters.AddWithValue("@visitorID", objVisitorGP.VisitorID);
                    objCmd.Parameters.AddWithValue("@visitorName", objVisitorGP.VisitorName);
                    objCmd.Parameters.AddWithValue("@address", objVisitorGP.Address);
                    objCmd.Parameters.AddWithValue("@contactNo", objVisitorGP.ContactNo);
                    objCmd.Parameters.AddWithValue("@vehicleNo", objVisitorGP.VehicleNo);
                    objCmd.Parameters.AddWithValue("@depositMaterial", objVisitorGP.DepositMaterial);
                    objCmd.Parameters.AddWithValue("@carryMaterial", objVisitorGP.CarryMaterial);
                    objCmd.Parameters.AddWithValue("@NoOfPerson", objVisitorGP.NoOfPersons);
                    objCmd.Parameters.AddWithValue("@companyName", objVisitorGP.CompanyName);
                    objCmd.Parameters.AddWithValue("@empID", objVisitorGP.EmployeeID);
                    objCmd.Parameters.AddWithValue("@toMeet", objVisitorGP.ToMeet);
                    objCmd.Parameters.AddWithValue("@purpose", objVisitorGP.Purpose);
                    objCmd.Parameters.AddWithValue("@timeIn", objVisitorGP.TimeIn);

                    if (objVisitorGP.TimeOut == DateTime.MinValue)
                    {
                        objCmd.Parameters.AddWithValue("@timeOut", DBNull.Value);
                    }
                    else
                    {
                        objCmd.Parameters.AddWithValue("@timeOut", objVisitorGP.TimeOut);
                    }

                    //objCmd.Parameters.AddWithValue("@imgFileName", objVisitorGP.ImgFileName);
                    objCmd.Parameters.AddWithValue("@appointmentNo", objVisitorGP.AppointmentNo);
                    objCmd.Parameters.AddWithValue("@empMobile", objVisitorGP.EmpMobile);
                    objCmd.Parameters.AddWithValue("@exPersons", objVisitorGP.ExtraPersons);

                    if (objVisitorGP.IsNew)
                    {
                        objCmd.Parameters.AddWithValue("@StDate", DateTime.Now);
                        objCmd.Parameters.AddWithValue("@CrBy", objCurUser.LoginName);
                        objCmd.Parameters.AddWithValue("@VImage", objVisitorGP.VisitorImage);

                        objVisitorGP.DBID       = General.GenerateDBID(Conn, "VISITORGATEPASS");
                        objVisitorGP.GatePassNo = string.Format("{0:yyMMdd}", dt) + Convert.ToString(objVisitorGP.DBID).PadLeft(4, Convert.ToChar(48));
                    }
                    objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now);
                    objCmd.Parameters.AddWithValue("@ModBy", objCurUser.LoginName);
                    objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName());

                    objCmd.Parameters.AddWithValue("@gatePassNo", objVisitorGP.GatePassNo);
                    objCmd.Parameters.AddWithValue("@dbID", objVisitorGP.DBID);

                    if (Conn.State != ConnectionState.Open)
                    {
                        Conn.Open();
                    }
                    result = objCmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            return(result > 0);
        }
예제 #9
0
        /// <summary>
        /// Fills values fetched from Database to Object objVisitorGP
        /// </summary>
        /// <param name="myDataRec">Record Object containing data values.</param>
        /// <returns>Returns object ObjVisitorGP containing Data values from Database.</returns>
        private static VisitorGatePass FillDataRecord(IDataRecord myDataRec)
        {
            VisitorGatePass objVisitorGP = new VisitorGatePass();

            objVisitorGP.IsLoading   = true;
            objVisitorGP.DBID        = Convert.ToInt32(myDataRec["DBID"]);
            objVisitorGP.GatePassNo  = Convert.ToString(myDataRec["GATEPASSNO"]);
            objVisitorGP.GateDate    = Convert.ToDateTime(myDataRec["GATEDATE"]);
            objVisitorGP.VisitorID   = Convert.ToInt32(myDataRec["VISITORID"]);
            objVisitorGP.VisitorName = Convert.ToString(myDataRec["NAME"]);
            objVisitorGP.Address     = Convert.ToString(myDataRec["ADDRESS"]);
            objVisitorGP.ContactNo   = Convert.ToString(myDataRec["CONTACTNO"]);

            if (!myDataRec.IsDBNull(myDataRec.GetOrdinal("VEHICLENO")))
            {
                objVisitorGP.VehicleNo = Convert.ToString(myDataRec["VEHICLENO"]);
            }
            if (!myDataRec.IsDBNull(myDataRec.GetOrdinal("DEPOSITEDMATERIAL")))
            {
                objVisitorGP.DepositMaterial = Convert.ToString(myDataRec["DEPOSITEDMATERIAL"]);
            }
            if (!myDataRec.IsDBNull(myDataRec.GetOrdinal("CARRYMATERIAL")))
            {
                objVisitorGP.CarryMaterial = Convert.ToString(myDataRec["CARRYMATERIAL"]);
            }

            objVisitorGP.NoOfPersons = Convert.ToInt32(myDataRec["NOOFPERSONS"]);
            objVisitorGP.CompanyName = Convert.ToString(myDataRec["COMPANY"]);
            objVisitorGP.EmployeeID  = Convert.ToInt32(myDataRec["EMPID"]);
            objVisitorGP.ToMeet      = Convert.ToString(myDataRec["TOMEET"]);
            objVisitorGP.Purpose     = Convert.ToString(myDataRec["PURPOSE"]);
            objVisitorGP.TimeIn      = Convert.ToDateTime(myDataRec["TIMEIN"]);

            if (!myDataRec.IsDBNull(myDataRec.GetOrdinal("TIMEOUT")))
            {
                objVisitorGP.TimeOut = Convert.ToDateTime(myDataRec["TIMEOUT"]);
            }
            //objVisitorGP.ImgFileName = Convert.ToString(myDataRec["IMGFILENAME"]);

            if (!myDataRec.IsDBNull(myDataRec.GetOrdinal("APPOINTMENTNO")))
            {
                objVisitorGP.AppointmentNo = Convert.ToString(myDataRec["APPOINTMENTNO"]);
            }
            objVisitorGP.EmpMobile = Convert.ToString(myDataRec["EMPMOBILE"]);

            if (!myDataRec.IsDBNull(myDataRec.GetOrdinal("EXPERSONS")))
            {
                objVisitorGP.ExtraPersons = Convert.ToInt32(myDataRec["EXPERSONS"]);
            }

            if (!myDataRec.IsDBNull(myDataRec.GetOrdinal("VIMAGE")))
            {
                objVisitorGP.VisitorImage = (byte[])myDataRec["VIMAGE"];
            }

            objVisitorGP.IsNew     = false;
            objVisitorGP.IsEdited  = false;
            objVisitorGP.IsDeleted = false;
            objVisitorGP.IsLoading = false;

            return(objVisitorGP);
        }
예제 #10
0
 /// <summary>
 /// Checks whether current Record already exists or not.
 /// </summary>
 /// <param name="objDept">Object containing all Data Values.</param>
 /// <returns>boolean value True if Record already Exists into Database
 /// otherwise returns False.</returns>
 public static bool IsGatePassExist(VisitorGatePass objVisitorGP)
 {
     return(IsGatePassExist(objVisitorGP));
 }
예제 #11
0
 public frmVisitorGPProp(VisitorGatePass objVisitorGP, User objCurUser)
 {
     this.objVisitorGP = objVisitorGP;
     objUser           = objCurUser;
     InitializeComponent();
 }