private void SaveData() { try { string strConfirmDate = ""; string strTerm = ""; if (string.IsNullOrEmpty(txtConfirmDate.Text.Trim()) == false) { strConfirmDate = Common.ReturnDate(txtConfirmDate.Text.Trim()); } if (hfIsUpdate.Value == "Y") { hfId.Value = hfId.Value; } else { hfId.Value = Common.getMaxId("AppraisalMst", "AppId"); } //objAppMgr.InsertAppraisal(hfId.Value.ToString(), txtEmpID.Text.Trim(), strEntryDate, ddlFiscalYr.SelectedValue.ToString(), strTerm, txtTotalRating.Text, txtOverallRating.Text , //txtRemarks.Text.Trim(), Session["USERID"].ToString(), Common.SetDateTime(DateTime.Now.ToString()), grPerformance, hfIsUpdate.Value.ToString()); //if (hfIsUpdate.Value == "N") // lblMsg.Text = "Record Saved Successfully"; //else // lblMsg.Text = "Record Updated Successfully"; clsPerformanceAppraisal objPAppraisal = new clsPerformanceAppraisal(); objPAppraisal.AppId = hfId.Value; objPAppraisal.EmpId = txtEmpID.Text.Trim(); objPAppraisal.EntryDate = strConfirmDate; objPAppraisal.FiscalYrId = ddlFiscalYr.SelectedValue.ToString(); objPAppraisal.IsMidTerm = strTerm; objPAppraisal.InsertedBy = Session["USERID"].ToString(); objPAppraisal.InsertedDate = Common.SetDateTime(DateTime.Now.ToString()); objAppMgr.InsertAppraisal(objPAppraisal, grPerformance, hfIsUpdate.Value.ToString()); lblMsg.Text = Common.GetMessage(hfIsUpdate.Value.ToString(), "N"); this.EntryMode(false); this.ClearControls(); } catch (Exception ex) { lblMsg.Text = ""; throw (ex); } }
//public void InsertAppraisal(string strAppId, string strEmpId, string strEntryDate, string strFiscalYrId, string strIsMidTerm, string strTotalRating, // string strOverallRating, string strRemarks, string strInsBy, string strInsDate, GridView grActivity, string strIsUpdate) //{ // SqlCommand[] command = new SqlCommand[grActivity.Rows.Count + 2]; // command[0] = new SqlCommand("proc_Insert_AppraisalMst"); // command[0].CommandType = CommandType.StoredProcedure; // SqlParameter p_AppId = command[0].Parameters.Add("AppId", SqlDbType.BigInt); // p_AppId.Direction = ParameterDirection.Input; // p_AppId.Value = strAppId; // SqlParameter p_EmpID = command[0].Parameters.Add("EmpId", SqlDbType.VarChar); // p_EmpID.Direction = ParameterDirection.Input; // p_EmpID.Value = strEmpId; // SqlParameter p_EntryDate = command[0].Parameters.Add("EntryDate", DBNull.Value); // p_EntryDate.Direction = ParameterDirection.Input; // p_EntryDate.IsNullable = true; // if (strEntryDate != "") // p_EntryDate.Value = strEntryDate; // SqlParameter p_FiscalYrId = command[0].Parameters.Add("FiscalYrId", SqlDbType.BigInt); // p_FiscalYrId.Direction = ParameterDirection.Input; // p_FiscalYrId.Value = strFiscalYrId; // SqlParameter p_IsMidTerm = command[0].Parameters.Add("IsMidTerm", SqlDbType.Char); // p_IsMidTerm.Direction = ParameterDirection.Input; // p_IsMidTerm.Value = strIsMidTerm; // SqlParameter p_TotalRating = command[0].Parameters.Add("TotalRating", DBNull.Value); // p_TotalRating.Direction = ParameterDirection.Input; // p_TotalRating.IsNullable = true; // if (strTotalRating != "") // p_TotalRating.Value = strTotalRating; // SqlParameter p_OverallRating = command[0].Parameters.Add("OverallRating", DBNull.Value); // p_OverallRating.Direction = ParameterDirection.Input; // p_OverallRating.IsNullable = true; // if (strOverallRating != "") // p_OverallRating.Value = strOverallRating; // SqlParameter p_Remarks = command[0].Parameters.Add("Remarks", SqlDbType.VarChar); // p_Remarks.Direction = ParameterDirection.Input; // p_Remarks.Value = strRemarks; // SqlParameter p_InsertedBy = command[0].Parameters.Add("InsertedBy", SqlDbType.VarChar); // p_InsertedBy.Direction = ParameterDirection.Input; // p_InsertedBy.Value = strInsBy; // SqlParameter p_InsertedDate = command[0].Parameters.Add("InsertedDate", SqlDbType.DateTime); // p_InsertedDate.Direction = ParameterDirection.Input; // p_InsertedDate.Value = strInsDate; // SqlParameter p_IsUpdate = command[0].Parameters.Add("IsUpdate", SqlDbType.Char); // p_IsUpdate.Direction = ParameterDirection.Input; // p_IsUpdate.Value = strIsUpdate; // if (strIsMidTerm == "N") // { // command[1] = new SqlCommand("proc_Delete_AppraisalDet"); // command[1].CommandType = CommandType.StoredProcedure; // p_AppId = command[1].Parameters.Add("AppId", SqlDbType.BigInt); // p_AppId.Direction = ParameterDirection.Input; // p_AppId.Value = strAppId; // int i = 2; // foreach (GridViewRow gRow in grActivity.Rows) // { // command[i] = new SqlCommand("proc_Insert_AppraisalDet"); // command[i].CommandType = CommandType.StoredProcedure; // p_AppId = command[i].Parameters.Add("AppId", SqlDbType.BigInt); // p_AppId.Direction = ParameterDirection.Input; // p_AppId.Value = strAppId; // SqlParameter p_ActivityName = command[i].Parameters.Add("ActivityName", SqlDbType.VarChar); // p_ActivityName.Direction = ParameterDirection.Input; // p_ActivityName.Value = gRow.Cells[2].Text.Trim(); // SqlParameter p_ActivityDesc = command[i].Parameters.Add("ActivityDesc", SqlDbType.VarChar); // p_ActivityDesc.Direction = ParameterDirection.Input; // p_ActivityDesc.Value = gRow.Cells[3].Text.Trim(); // SqlParameter p_Rating = command[i].Parameters.Add("Rating", SqlDbType.Decimal); // p_Rating.Direction = ParameterDirection.Input; // p_Rating.Value = gRow.Cells[4].Text.Trim(); // p_InsertedBy = command[i].Parameters.Add("InsertedBy", SqlDbType.VarChar); // p_InsertedBy.Direction = ParameterDirection.Input; // p_InsertedBy.Value = strInsBy; // p_InsertedDate = command[i].Parameters.Add("InsertedDate", SqlDbType.DateTime); // p_InsertedDate.Direction = ParameterDirection.Input; // p_InsertedDate.Value = strInsDate; // i++; // } // } // try // { // objDC.MakeTransaction(command); // } // catch (Exception ex) // { // throw (ex); // } // finally // { // command = null; // } //} public void InsertAppraisal(clsPerformanceAppraisal objAPPppraisal, GridView grActivity, string strIsUpdate) { SqlCommand[] command = new SqlCommand[grActivity.Rows.Count + 2]; command[0] = new SqlCommand("proc_Insert_AppraisalMst"); command[0].CommandType = CommandType.StoredProcedure; SqlParameter p_AppId = command[0].Parameters.Add("AppId", SqlDbType.BigInt); p_AppId.Direction = ParameterDirection.Input; p_AppId.Value = Convert.ToInt32(objAPPppraisal.AppId); SqlParameter p_EmpID = command[0].Parameters.Add("EmpId", SqlDbType.VarChar); p_EmpID.Direction = ParameterDirection.Input; p_EmpID.Value = objAPPppraisal.EmpId; SqlParameter p_EntryDate = command[0].Parameters.Add("EntryDate", DBNull.Value); p_EntryDate.Direction = ParameterDirection.Input; p_EntryDate.IsNullable = true; if (objAPPppraisal.EntryDate != "") { p_EntryDate.Value = objAPPppraisal.EntryDate; } SqlParameter p_FiscalYrId = command[0].Parameters.Add("FiscalYrId", SqlDbType.BigInt); p_FiscalYrId.Direction = ParameterDirection.Input; p_FiscalYrId.Value = objAPPppraisal.FiscalYrId; SqlParameter p_IsMidTerm = command[0].Parameters.Add("IsMidTerm", SqlDbType.Char); p_IsMidTerm.Direction = ParameterDirection.Input; p_IsMidTerm.Value = objAPPppraisal.IsMidTerm; SqlParameter p_TotalRating = command[0].Parameters.Add("TotalRating", DBNull.Value); p_TotalRating.Direction = ParameterDirection.Input; p_TotalRating.IsNullable = true; if (objAPPppraisal.TotlalRating != "") { p_TotalRating.Value = objAPPppraisal.TotlalRating; } SqlParameter p_OverallRating = command[0].Parameters.Add("OverallRating", DBNull.Value); p_OverallRating.Direction = ParameterDirection.Input; p_OverallRating.IsNullable = true; if (objAPPppraisal.Overallrating != "") { p_OverallRating.Value = objAPPppraisal.Overallrating; } SqlParameter p_Remarks = command[0].Parameters.Add("Remarks", SqlDbType.VarChar); p_Remarks.Direction = ParameterDirection.Input; p_Remarks.Value = objAPPppraisal.Remarks; SqlParameter p_InsertedBy = command[0].Parameters.Add("InsertedBy", SqlDbType.VarChar); p_InsertedBy.Direction = ParameterDirection.Input; p_InsertedBy.Value = objAPPppraisal.InsertedBy; SqlParameter p_InsertedDate = command[0].Parameters.Add("InsertedDate", SqlDbType.DateTime); p_InsertedDate.Direction = ParameterDirection.Input; p_InsertedDate.Value = objAPPppraisal.InsertedDate; SqlParameter p_IsUpdate = command[0].Parameters.Add("IsUpdate", SqlDbType.Char); p_IsUpdate.Direction = ParameterDirection.Input; p_IsUpdate.Value = strIsUpdate; if (objAPPppraisal.IsMidTerm == "N") { command[1] = new SqlCommand("proc_Delete_AppraisalDet"); command[1].CommandType = CommandType.StoredProcedure; p_AppId = command[1].Parameters.Add("AppId", SqlDbType.BigInt); p_AppId.Direction = ParameterDirection.Input; p_AppId.Value = Convert.ToInt32(objAPPppraisal.AppId); int i = 2; foreach (GridViewRow gRow in grActivity.Rows) { command[i] = new SqlCommand("proc_Insert_AppraisalDet"); command[i].CommandType = CommandType.StoredProcedure; p_AppId = command[i].Parameters.Add("AppId", SqlDbType.BigInt); p_AppId.Direction = ParameterDirection.Input; p_AppId.Value = Convert.ToInt32(objAPPppraisal.AppId); SqlParameter p_ActivityName = command[i].Parameters.Add("ActivityName", SqlDbType.VarChar); p_ActivityName.Direction = ParameterDirection.Input; p_ActivityName.Value = gRow.Cells[1].Text.Trim(); SqlParameter p_ActivityDesc = command[i].Parameters.Add("ActivityDesc", SqlDbType.VarChar); p_ActivityDesc.Direction = ParameterDirection.Input; p_ActivityDesc.Value = gRow.Cells[2].Text.Trim(); SqlParameter p_Rating = command[i].Parameters.Add("Rating", SqlDbType.Decimal); p_Rating.Direction = ParameterDirection.Input; p_Rating.Value = Convert.ToDecimal(gRow.Cells[3].Text.Trim()); p_InsertedBy = command[i].Parameters.Add("InsertedBy", SqlDbType.VarChar); p_InsertedBy.Direction = ParameterDirection.Input; p_InsertedBy.Value = objAPPppraisal.InsertedBy; p_InsertedDate = command[i].Parameters.Add("InsertedDate", SqlDbType.DateTime); p_InsertedDate.Direction = ParameterDirection.Input; p_InsertedDate.Value = objAPPppraisal.InsertedDate; i++; } } try { objDC.MakeTransaction(command); } catch (Exception ex) { throw (ex); } finally { command = null; } }