Ejemplo n.º 1
0
        public static List <ATTAppointee> SetAppointee(DataRow appRow)
        {
            try
            {
                List <ATTAppointee> lstAppointee = new List <ATTAppointee>();
                foreach (DataRow row in tblAppointee.Rows)
                {
                    if (int.Parse(appRow["ORG_ID"].ToString()) == int.Parse(row["ORG_ID"].ToString()) &&
                        int.Parse(appRow["APPOINTMENT_ID"].ToString()) == int.Parse(row["APPOINTMENT_ID"].ToString())
                        )
                    {
                        int?   appointeeID;
                        string appointee = "";
                        string outdoorAppointeeOrgName;

                        if (row["APPOINTEE_ID"].ToString() != "")
                        {
                            appointeeID = int.Parse(row["APPOINTEE_ID"].ToString());
                            appointee   = row["FIRST_NAME"].ToString() +
                                          (row["MID_NAME"].ToString() == "" ? "" : " " + row["MID_NAME"].ToString()) +
                                          (row["SUR_NAME"].ToString() == "" ? "" : " " + row["SUR_NAME"].ToString());

                            outdoorAppointeeOrgName = "";
                        }
                        else
                        {
                            appointeeID             = null;
                            appointee               = row["OUTDOOR_APPOINTEE_NAME"].ToString();
                            outdoorAppointeeOrgName = row["OUTDOOR_APPOINTEE_ORG_NAME"].ToString();
                        }

                        ATTAppointee objAppointee = new ATTAppointee();
                        objAppointee.OrgID             = int.Parse(row["ORG_ID"].ToString());
                        objAppointee.AppointmentID     = int.Parse(row["APPOINTMENT_ID"].ToString());
                        objAppointee.ApID              = int.Parse(row["AP_ID"].ToString());
                        objAppointee.AppointeeID       = appointeeID;
                        objAppointee.Appointee         = appointee;
                        objAppointee.IsIndoorAppointee = row["IS_INDOOR_APPOINTEE"].ToString();
                        objAppointee.Action            = "N";
                        objAppointee.OutdoorOrgName    = outdoorAppointeeOrgName;
                        objAppointee.EntryOn           = DateTime.Parse(row["ENTRY_ON"].ToString());
                        objAppointee.Flag              = row["flag"].ToString();
                        objAppointee.Remark            = row["remark"].ToString();

                        lstAppointee.Add(objAppointee);
                    }
                }
                return(lstAppointee);
            }
            catch (Exception ex)
            {
                throw(ex);
            }
        }
        public static bool SaveAppointee(ATTAppointee objAppointee, OracleTransaction Tran)
        {
            try
            {
                string saveSQL = "SP_ADD_APPOINTEE";
                //string appointeeIDs = "";
                string outdoorAppointeeName;
                string outdoorAppointeeOrgName;

                if (objAppointee.IsIndoorAppointee == "N")
                {
                    outdoorAppointeeName    = objAppointee.Appointee;
                    outdoorAppointeeOrgName = objAppointee.OutdoorOrgName;
                }
                else
                {
                    outdoorAppointeeName    = "";
                    outdoorAppointeeOrgName = "";
                }

                OracleParameter[] paramArray = new OracleParameter[11];

                //if (objAppointee.Action == "A")
                //{

                paramArray[0] = Utilities.GetOraParam(":P_ORG_ID", objAppointee.OrgID, OracleDbType.Int64, ParameterDirection.Input);
                paramArray[1] = Utilities.GetOraParam(":P_APPOINTMENT_ID", objAppointee.AppointmentID, OracleDbType.Int64, ParameterDirection.Input);
                paramArray[2] = Utilities.GetOraParam(":P_AP_ID", null, OracleDbType.Int64, ParameterDirection.InputOutput);
                paramArray[3] = Utilities.GetOraParam(":P_APPOINTEE_ID", objAppointee.AppointeeID, OracleDbType.Int64, ParameterDirection.InputOutput);
                paramArray[4] = Utilities.GetOraParam(":P_IS_INDOOR_APPOINTEE", objAppointee.IsIndoorAppointee, OracleDbType.Varchar2, ParameterDirection.Input);
                paramArray[5] = Utilities.GetOraParam(":P_OUTDOOR_APPOINTEE_NAME", outdoorAppointeeName, OracleDbType.Varchar2, ParameterDirection.Input);
                paramArray[6] = Utilities.GetOraParam(":P_OUTDOOR_APPOINTEE_ORG_NAME", outdoorAppointeeOrgName, OracleDbType.Varchar2, ParameterDirection.Input);

                paramArray[7] = Utilities.GetOraParam(":P_FLAG", objAppointee.Flag, OracleDbType.Varchar2, ParameterDirection.Input);
                paramArray[8] = Utilities.GetOraParam(":P_REMARK", objAppointee.Remark, OracleDbType.Varchar2, ParameterDirection.Input);

                paramArray[9]  = Utilities.GetOraParam(":P_ENTRY_BY", objAppointee.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input);
                paramArray[10] = Utilities.GetOraParam(":P_ENTRY_ON", objAppointee.EntryOn, OracleDbType.Date, ParameterDirection.Input);

                SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, saveSQL, paramArray);

                return(true);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        public static bool DeleteAppointee(ATTAppointment objAppointment, ATTAppointee objAppointee, OracleTransaction Tran)
        {
            try
            {
                string deleteSQL = "SP_DEL_APPOINTEE";
                int?   orgID;
                int?   appointmentID;
                //int? appointeeID ;
                int?apID;


                if (objAppointment != null)
                {
                    orgID         = objAppointment.OrgID;
                    appointmentID = objAppointment.AppointmentID;
                    //appointeeID = null;
                    apID = null;
                }
                else
                {
                    orgID         = objAppointee.OrgID;
                    appointmentID = objAppointee.AppointmentID;
                    //appointeeID = objAppointee.AppointeeID;
                    apID = objAppointee.ApID;
                }

                OracleParameter[] paramArray = new OracleParameter[3];
                paramArray[0] = Utilities.GetOraParam(":P_ORG_ID", orgID, OracleDbType.Int64, ParameterDirection.Input);
                paramArray[1] = Utilities.GetOraParam(":P_APPOINTMENT_ID", appointmentID, OracleDbType.Int64, ParameterDirection.Input);
                //paramArray[2] = Utilities.GetOraParam(":P_APPOINTEE_ID", appointeeID, OracleDbType.Int64, ParameterDirection.InputOutput);
                paramArray[2] = Utilities.GetOraParam(":P_AP_ID", apID, OracleDbType.Int64, ParameterDirection.Input);

                SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, deleteSQL, paramArray);

                return(true);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }