Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Check Leave Status
1. public bool CheckLeaveStatus(int empid, DateTime date)
{
bool temp = false;
int totalleave = 0;
string qry = "select joining from profile where
profileid=@id";
MySqlParameter idP = new MySqlParameter("@id", empid);
DataRow dr =
MySqlHelper.ExecuteDataRow(Common.GetConnectionString(), qry, idP);
if (dr != null)
{
DateTime joiningdate =
Convert.ToDateTime(dr["joining"]);
int legaldate = joiningdate.Day;
if (legaldate <= 15)
{
totalleave += 2;
}
else
{
totalleave += 0;
}
//TimeSpan t1 = date - joiningdate;
int monthspassed = Common.MonthDifference(date,
joiningdate);
if (monthspassed > 3)//then he is allowd to take leave
{
int startmonth = joiningdate.Month + 1;
int endmonth = date.Month;
int monthdiffernce = endmonth - startmonth;
/*here i am having problem how can i written logic for
two years passed from joiningdate and after that every month again
two leaves issued .in this previous leave is not taken care off and
leave taken count from new logic because two years passed */
if (monthdiffernce > 24)
{
monthdiffernce = 24;
}
int leaves = (monthdiffernce) * 2;
int allowedleaves = leaves + totalleave;
int availablelaves = allowedleaves -
LeaveTaken(empid);
if (availablelaves > 0)
{
temp = true;
}
}
//DateTime previousdate = date.AddYears(-2);
}
2. return temp;
}
public int LeaveTaken(int empid)
{
try
{
int taken = 0;
string qry = "select count(*) from leavestatus where
empid=@id";
MySqlParameter idP = new MySqlParameter("@id", empid);
taken =
Convert.ToInt32(MySqlHelper.ExecuteScalar(Common.GetConnectionString
(), qry, idP));
return taken;
}
catch
{
return 0;
}
}
public void AddLeaves(int empid, DateTime date, string status)
{
if (status == "L")
{
string qry = "insert into
leavestatus(empid,takenon)values(@empid,@takenon)";
MySqlParameter idP = new MySqlParameter("@empid",
empid);
MySqlParameter takenonP = new MySqlParameter("@takenon",
date);
MySqlParameter[] p = { idP, takenonP };
MySqlHelper.ExecuteNonQuery(Common.GetConnectionString(), qry, p);
}
}
3. -- phpMyAdminSQLDump
-- version 3.2.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 12, 2013 at01:24 AM
-- Server version: 5.1.41
-- PHP Version: 5.3.1
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!40101 SET
@OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET
@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
4. /*!40101 SET
@OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SETNAMESutf8 */;
--
-- Database: `latrix`
--
-- --------------------------------------------------------
--
-- Table structure for table `designation`
--
CREATE TABLE IF NOT EXISTS `designation` (
`desig_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`desig_id`),
UNIQUE KEY `desig_id_UNIQUE`(`desig_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1AUTO_INCREMENT=3;
--
-- Dumpingdatafor table `designation`
--
INSERT INTO `designation` (`desig_id`, `name`) VALUES
(1, 'Manager'),
(2, 'Office Assistance');
-- --------------------------------------------------------
--
-- Table structure for table `employees`
--
CREATE TABLE IF NOT EXISTS `employees`(
`emp_id`int(11) unsigned NOT NULL AUTO_INCREMENT,
`title_id` int(11) unsigned NOT NULL,
`name` varchar(60) NOT NULL DEFAULT 'unknown',
`fileno` varchar(20) NOT NULL DEFAULT 'TBD',
`max_leave` int(11) NOT NULL,
`mobile_phone` varchar(15) NOT NULL,
5. `leave_left` int(10) unsigned NOTNULL DEFAULT '0',
`designation_desig_id` int(11) NOT NULL,
PRIMARY KEY (`emp_id`),
KEY `idx_title` (`title_id`),
KEY `idx_payroll`(`fileno`),
KEY `idx_name` (`name`),
KEY `fk_employees_designation1` (`designation_desig_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1AUTO_INCREMENT=3;
--
-- Dumpingdatafor table `employees`
--
INSERT INTO `employees`(`emp_id`, `title_id`, `name`, `fileno`, `max_leave`,
`mobile_phone`, `leave_left`, `designation_desig_id`) VALUES
(1, 1, 'Admin', '0001', 0, 'no phone', 0, 0),
(2, 1, 'Krishno', '1', 0, '', 0, 0);
-- --------------------------------------------------------
--
-- Table structure for table `emp_leave`
--
CREATE TABLE IF NOT EXISTS `emp_leave`(
`emp_leave_id`int(10) unsigned NOTNULL AUTO_INCREMENT,
`emp_id`int(11) unsigned NOT NULL,
`start_date` date NOT NULL DEFAULT '0000-00-00',
`end_date` date NOT NULL DEFAULT '0000-00-00',
`workdays`decimal(4,1) unsigned NOTNULL DEFAULT '0.0',
`type_id` int(11) unsigned NOTNULL,
`is_half_day` tinyint(1) NOT NULL DEFAULT '0',
`is_am` tinyint(1) NOT NULL DEFAULT '0',
`note` text NOT NULL,
`submit_date` date NOT NULL,
`approved`tinyint(1) DEFAULT '0',
`approval_date`date NOT NULL,
`approval_emp_id` int(10) unsigned NOTNULL,
PRIMARY KEY (`emp_leave_id`),
KEY `idx_type` (`type_id`),
KEY `idx_start` (`start_date`),
KEY `fk_emp_leave_emp` (`emp_id`)
7. -- Table structure for table `titles`
--
CREATE TABLE IF NOT EXISTS `titles` (
`title_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
PRIMARY KEY (`title_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1AUTO_INCREMENT=5;
--
-- Dumpingdatafor table `titles`
--
INSERT INTO `titles` (`title_id`, `name`) VALUES
(1, 'Mr.'),
(2, 'Mrs.'),
(3, 'Ms.'),
(4, 'Dr.');
-- --------------------------------------------------------
--
-- Table structure for table `yesno`
--
CREATE TABLE IF NOT EXISTS `yesno` (
`idyesno`int(11) NOT NULL,
`option` varchar(5) NOT NULL,
PRIMARY KEY (`idyesno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumpingdatafor table `yesno`
--
INSERT INTO `yesno`(`idyesno`, `option`) VALUES
(1, 'Yes'),
(2, 'No');
--
-- Constraints for dumped tables
--
8. --
-- Constraints for table `employees`
--
ALTER TABLE `employees`
ADD CONSTRAINT `fk_employees_designation1` FOREIGN KEY
(`designation_desig_id`) REFERENCES `designation`(`desig_id`) ON
DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `employees_ibfk_4`FOREIGN KEY (`title_id`)
REFERENCES `titles` (`title_id`) ON DELETE NO ACTION ON UPDATE NO
ACTION;
--
-- Constraints for table `emp_leave`
--
ALTER TABLE `emp_leave`
ADD CONSTRAINT `emp_leave_ibfk_1`FOREIGN KEY (`type_id`)
REFERENCES `leave_types`(`leave_type_id`) ON DELETE NO ACTION ON
UPDATE NO ACTION,
ADD CONSTRAINT `emp_leave_ibfk_2`FOREIGN KEY (`emp_id`)
REFERENCES `employees`(`emp_id`) ON DELETE NO ACTION ON UPDATE
NO ACTION;
/*!40101 SETCHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT
*/;
/*!40101 SET
CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS*/;
/*!40101 SET
COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
mysql