示例#1
0
        public void InsertRecord(Objects.EmployeeLeaves obj)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SP_EmployeeLeavesInsert";

                cmd.Parameters.AddWithValue("@EmployeeID", obj.EmployeeID);
                cmd.Parameters.AddWithValue("@EntryDate", obj.EntryDate);
                cmd.Parameters.AddWithValue("@LeavFrom", obj.LeavFrom);
                cmd.Parameters.AddWithValue("@LeaveTo", obj.LeaveTo);
                cmd.Parameters.AddWithValue("@Remarks", obj.Remarks);
                cmd.Parameters.AddWithValue("@UserID", obj.UserID);
                cmd.Parameters.AddWithValue("@Unpaid", obj.Unpaid);

                new Database(connectionstring).ExecuteNonQueryOnly(cmd);
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtEmployeeName.Text.Trim() == string.Empty)
                {
                    Message.ShowMessage(MyMessages.MessageType.MissingInfo, "Please Select an Employee first.");
                    txtEmployeeID.Focus();
                    return;
                }

                if (dtToDate.Value < dtFromDate.Value)
                {
                    Message.ShowMessage(MyMessages.MessageType.MissingInfo, "Leave To date must be greater than From Date.");
                    dtToDate.Focus();
                    return;
                }


                //DataTable dt = new DataTable();

                //if (!vOpenMode)
                //{
                //    dt = objDAL.getRecord(string.Format(" AND (convert(datetime,Convert(varchar,DailyAttendance.AttendaceDateTime,1)) = Convert(Datetime,(convert(varchar,convert(Datetime,'{0} 00:00:00',102),1)))) and Employees.EmployeeID={1}", dtFromDate.Value.ToShortDateString(), txtEmployeeID.Text));
                //    if (dt.Rows.Count > 0)
                //    {

                //        Message.ShowMessage(MyMessages.MessageType.General, "Attendance Already Entered.");
                //        return;
                //    }
                //}
                //else
                //{
                //    dt = objDAL.getRecord(string.Format(" AND (convert(datetime,Convert(varchar,DailyAttendance.AttendaceDateTime,1)) = Convert(Datetime,(convert(varchar,convert(Datetime,'{0} 00:00:00',102),1)))) AND Employees.EmployeeID={1} AND DailyAttendance.AttendanceID<>{2}", dtFromDate.Value.ToShortDateString(),txtEmployeeID.Text,txtID.Text));
                //    if (dt.Rows.Count > 0)
                //    {
                //        Message.ShowMessage(MyMessages.MessageType.General, "Attendance Already Entered.");
                //        return;
                //    }
                //}


                Objects.EmployeeLeaves obj = new Objects.EmployeeLeaves();
                obj.LeaveID    = Int64.Parse(txtID.Text);
                obj.EmployeeID = Int64.Parse(txtEmployeeID.Text);
                obj.EntryDate  = DateTime.Now;
                obj.LeavFrom   = dtFromDate.Value;
                obj.LeaveTo    = dtToDate.Value;
                obj.Unpaid     = chkWithoutPay.Checked;
                obj.Remarks    = txtRemarks.Text.Trim();
                obj.UserID     = vUserID;

                if (!vOpenMode)
                {
                    //Insert
                    objDAL.InsertRecord(obj);
                }
                else
                {
                    // UPdate
                    objDAL.UpdateRecord(obj);
                }

                Message.ShowMessage(MyMessages.MessageType.SaveRecord);
                LoadGrid();
                btnClear_Click(sender, e);
            }
            catch (Exception exc)
            {
                Message.ShowMessage(MyMessages.MessageType.Error, exc.Message);
            }
        }