Procedure to Save Data and Edit Data in Form
Alter PROCEDURE SaveEmployee
@Id bigint,
@Name nvarchar(50),
@FatherName nvarchar(50),
@MotherName nvarchar(50),
@DesignationId bigint,
@CompanyId bigint,
@DepartmentId bigint,
@DOB Date
AS
BEGIN
if(@Id=0)
begin
INSERT INTO Employee
(
Name ,
FatherName ,
MotherName ,
DOB,
DesignationId,
CompanyId ,
DepartmentId
)
VALUES
(
@Name ,
@FatherName ,
@MotherName ,
@DOB ,
@DesignationId ,
@CompanyId ,
@DepartmentId
)
END
else
BEGIN
UPDATE Employee
SET
Name=@Name ,
FatherName =@FatherName,
MotherName =@MotherName ,
DOB = @DOB ,
DesignationId = @DesignationId ,
CompanyId=@CompanyId ,
DepartmentId = @DepartmentId
WHERE EmployeeId =@Id
END
IF (@Id = 0)
BEGIN
SELECT max(EmployeeId) EmployeeId FROM Employee
END
ELSE
BEGIN
SELECT EmployeeId FROM Employee
WHERE EmployeeId=@Id
END
end