Ejemplo n.º 1
0
        public override bool Add(object data)
        {
            List <SqlParameter> parameterList = new List <SqlParameter>();

            string         procName    = "sp_T_Planing_Action_BFRemoval_Insert";
            string         PID         = "";
            SqlConnection  conn        = OpenConnection();
            SqlTransaction transaction = conn.BeginTransaction();

            isCan = true;
            try
            {
                obj     = (T_Planing_Action_BFRemovalDTO)data;
                command = new SqlCommand(procName, conn, transaction);

                command.CommandType = CommandType.StoredProcedure;



                if (data != null)
                {
                    parameterList.AddRange(GetParameters(procName, obj, transaction).ToArray());
                    command.Parameters.AddRange(parameterList.ToArray());
                }

                command.ExecuteNonQuery();

                PID = obj.PID;



                if (obj.DeleteFiles != null && obj.DeleteFiles.Length > 0)
                {
                    procName = "sp_T_Planing_Action_BFRemoval_Files_Delete";
                    foreach (var fileNo in obj.DeleteFiles.Split(','))
                    {
                        if (fileNo != "")
                        {
                            command = new SqlCommand(procName, conn, transaction);

                            command.CommandType = CommandType.StoredProcedure;
                            if (fileNo != null)
                            {
                                T_Planing_File file = new T_Planing_File();
                                file.PID      = PID;
                                file.No       = fileNo;
                                parameterList = new List <SqlParameter>();
                                parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                                command.Parameters.AddRange(parameterList.ToArray());
                                //  command.Parameters[0].Value = "";
                            }

                            command.ExecuteNonQuery();
                        }
                    }
                }

                if (obj.DeleteConditionFiles != null && obj.DeleteConditionFiles.Length > 0)
                {
                    procName = "[sp_T_Planing_Action_BFRemoval_ConditionFiles_Delete]";
                    foreach (var fileNo in obj.DeleteConditionFiles.Split(','))
                    {
                        if (fileNo != "")
                        {
                            command = new SqlCommand(procName, conn, transaction);

                            command.CommandType = CommandType.StoredProcedure;
                            if (fileNo != null)
                            {
                                T_Planing_File file = new T_Planing_File();
                                file.PID        = PID;
                                file.No         = fileNo;
                                file.UploadType = "3";
                                parameterList   = new List <SqlParameter>();
                                parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                                command.Parameters.AddRange(parameterList.ToArray());
                                //  command.Parameters[0].Value = "";
                            }

                            command.ExecuteNonQuery();
                        }
                    }
                }



                procName = "sp_T_Planing_Action_BFRemoval_Files_Insert";
                if (obj.UploadFileList != null && obj.UploadFileList.Count > 0)
                {
                    foreach (T_Planing_File file in obj.UploadFileList)
                    {
                        file.PID = PID;

                        command = new SqlCommand(procName, conn, transaction);

                        command.CommandType = CommandType.StoredProcedure;
                        if (file != null)
                        {
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                            //  command.Parameters[0].Value = "";
                        }

                        command.ExecuteNonQuery();
                    }
                }



                procName = "[sp_T_Planing_Action_BFRemoval_Condition_Insert]";
                if (obj.ConditionList != null && obj.ConditionList.Count > 0)
                {
                    foreach (T_Planing_Action_BFRemoval_ConditionDTO dto in obj.ConditionList)
                    {
                        dto.PID = PID;

                        command = new SqlCommand(procName, conn, transaction);

                        command.CommandType = CommandType.StoredProcedure;
                        if (dto != null)
                        {
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, dto, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                            //  command.Parameters[0].Value = "";
                        }

                        command.ExecuteNonQuery();
                    }
                }


                transaction.Commit();
            }
            catch (Exception ex)
            {
                isCan = false;
                transaction.Rollback();
                throw new Exception(ex.Message);
            }
            finally
            {
                CloseConnection();
            }
            return(isCan);
        }
Ejemplo n.º 2
0
        public override bool Add(object planObj)
        {
            List <SqlParameter> parameterList = new List <SqlParameter>();

            string         procName    = "sp_T_Planing_Insert";
            string         PID         = "";
            SqlConnection  conn        = OpenConnection();
            SqlTransaction transaction = conn.BeginTransaction();

            isCan = true;
            try
            {
                command = new SqlCommand(procName, conn, transaction);

                command.CommandType = CommandType.StoredProcedure;



                if (planObj != null)
                {
                    ((T_PlaningDTO)planObj).SpecSDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).SpecSDate);
                    ((T_PlaningDTO)planObj).SpecEDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).SpecEDate);

                    ((T_PlaningDTO)planObj).POSDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).POSDate);
                    ((T_PlaningDTO)planObj).POEDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).POEDate);


                    ((T_PlaningDTO)planObj).ActionSDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).ActionSDate);
                    ((T_PlaningDTO)planObj).ActionEDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).ActionEDate);


                    parameterList.AddRange(GetParameters(procName, planObj, transaction).ToArray());

                    command.Parameters.AddRange(parameterList.ToArray());
                    if (((T_PlaningDTO)planObj).PID == null ||
                        ((T_PlaningDTO)planObj).PID == "")
                    {
                        command.Parameters[0].Value = "";
                    }
                }

                command.ExecuteNonQuery();

                PID = command.Parameters[0].Value.ToString();

                if (((T_PlaningDTO)planObj).DeleteFiles != null && ((T_PlaningDTO)planObj).DeleteFiles.Length > 0)
                {
                    procName = "sp_T_Planing_Files_Delete";
                    foreach (var fileNo in ((T_PlaningDTO)planObj).DeleteFiles.Split(','))
                    {
                        command = new SqlCommand(procName, conn, transaction);

                        command.CommandType = CommandType.StoredProcedure;
                        if (fileNo != null)
                        {
                            T_Planing_File file = new T_Planing_File();
                            file.PID      = PID;
                            file.No       = fileNo;
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                            //  command.Parameters[0].Value = "";
                        }

                        command.ExecuteNonQuery();
                    }
                }

                obj      = (T_PlaningDTO)planObj;
                obj.PID  = PID;
                procName = "sp_T_Planing_Files_Insert";
                if (obj.UploadFileList != null && obj.UploadFileList.Count > 0)
                {
                    foreach (T_Planing_File file in obj.UploadFileList)
                    {
                        file.PID = PID;

                        command = new SqlCommand(procName, conn, transaction);

                        command.CommandType = CommandType.StoredProcedure;
                        if (file != null)
                        {
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                            //  command.Parameters[0].Value = "";
                        }

                        command.ExecuteNonQuery();
                    }
                }

                transaction.Commit();
            }
            catch (Exception ex)
            {
                isCan = false;
                transaction.Rollback();
                throw new Exception(ex.Message);
            }
            finally
            {
                CloseConnection();
            }
            return(isCan);
        }
Ejemplo n.º 3
0
        public override bool Add(object data)
        {
            List <SqlParameter> parameterList = new List <SqlParameter>();

            string         procName    = "sp_T_Planing_Action_AfterAppliedCoating_Insert";
            string         PID         = "";
            SqlConnection  conn        = OpenConnection();
            SqlTransaction transaction = conn.BeginTransaction();

            isCan = true;
            try
            {
                obj = (T_Planing_Action_AfterAppliedCoatingDTO)data;

                //obj.DateINstalled = ConvertX.MMddYY(obj.DateINstalled);

                command = new SqlCommand(procName, conn, transaction);

                command.CommandType = CommandType.StoredProcedure;



                if (data != null)
                {
                    parameterList.AddRange(GetParameters(procName, obj, transaction).ToArray());
                    command.Parameters.AddRange(parameterList.ToArray());
                }

                command.ExecuteNonQuery();

                PID = obj.PID;

                if (obj.DeleteFiles != null && obj.DeleteFiles.Length > 0)
                {
                    procName = "sp_T_Planing_Action_AfterAppliedCoating_Files_Delete";
                    foreach (var fileNo in obj.DeleteFiles.Split(','))
                    {
                        if (fileNo != null && fileNo != "")
                        {
                            command = new SqlCommand(procName, conn, transaction);

                            command.CommandType = CommandType.StoredProcedure;

                            T_Planing_File file = new T_Planing_File();
                            file.PID      = PID;
                            file.No       = fileNo;
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                            //  command.Parameters[0].Value = "";


                            command.ExecuteNonQuery();
                        }
                    }
                }



                procName = "sp_T_Planing_Action_AfterAppliedCoating_Files_Insert";
                if (obj.UploadFileList != null && obj.UploadFileList.Count > 0)
                {
                    foreach (T_Planing_File file in obj.UploadFileList)
                    {
                        file.PID = PID;

                        command = new SqlCommand(procName, conn, transaction);

                        command.CommandType = CommandType.StoredProcedure;
                        if (file != null)
                        {
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                            //  command.Parameters[0].Value = "";
                        }

                        command.ExecuteNonQuery();
                    }
                }


                procName = "sp_T_Planing_Action_AfterAppliedCoating_DryFilmThickness_Insert";
                if (obj.DryFilmThicknessList != null && obj.DryFilmThicknessList.Count > 0)
                {
                    foreach (T_Planing_Action_AfterAppliedCoating_DryFilmDTO dto in obj.DryFilmThicknessList)
                    {
                        dto.PID = PID;

                        dto.ClockPosition1 = dto.ClockPosition1 == "" ? null: dto.ClockPosition1;
                        dto.ClockPosition2 = dto.ClockPosition2 == "" ? null : dto.ClockPosition2;
                        dto.ClockPosition3 = dto.ClockPosition3 == "" ? null : dto.ClockPosition3;
                        dto.ClockPosition4 = dto.ClockPosition4 == "" ? null : dto.ClockPosition4;
                        command            = new SqlCommand(procName, conn, transaction);

                        command.CommandType = CommandType.StoredProcedure;
                        if (dto != null)
                        {
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, dto, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                        }

                        command.ExecuteNonQuery();
                    }
                }



                transaction.Commit();
            }
            catch (Exception ex)
            {
                isCan = false;
                transaction.Rollback();
                throw new Exception(ex.Message);
            }
            finally
            {
                CloseConnection();
            }
            return(isCan);
        }
Ejemplo n.º 4
0
        public override bool Add(object data)
        {
            List <SqlParameter> parameterList = new List <SqlParameter>();

            string         procName    = "sp_T_Planing_Action_SiteSurvey_Insert";
            string         PID         = "";
            SqlConnection  conn        = OpenConnection();
            SqlTransaction transaction = conn.BeginTransaction();

            isCan = true;
            try
            {
                obj = (T_Planing_Action_SiteSurveyDTO)data;

                obj.DateINstalled = ConvertX.MMddYY(obj.DateINstalled);

                command = new SqlCommand(procName, conn, transaction);

                command.CommandType = CommandType.StoredProcedure;



                if (data != null)
                {
                    parameterList.AddRange(GetParameters(procName, obj, transaction).ToArray());
                    command.Parameters.AddRange(parameterList.ToArray());
                }

                command.ExecuteNonQuery();

                PID = obj.PID;

                /*  if (((T_PlaningDTO)obj).DeleteFiles != null && ((T_PlaningDTO)obj).DeleteFiles.Length > 0)
                 * {
                 *    procName = "sp_T_Planing_Files_Delete";
                 *    foreach (var fileNo in ((T_PlaningDTO)planObj).DeleteFiles.Split(','))
                 *    {
                 *
                 *        command = new SqlCommand(procName, conn, transaction);
                 *
                 *        command.CommandType = CommandType.StoredProcedure;
                 *        if (fileNo != null)
                 *        {
                 *            T_Planing_File file = new T_Planing_File();
                 *            file.PID = PID;
                 *            file.No = fileNo;
                 *            parameterList = new List<SqlParameter>();
                 *            parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());
                 *
                 *            command.Parameters.AddRange(parameterList.ToArray());
                 *            //  command.Parameters[0].Value = "";
                 *        }
                 *
                 *        command.ExecuteNonQuery();
                 *
                 *
                 *    }
                 * }*/


                if (obj.DeleteFiles != null && obj.DeleteFiles.Length > 0)
                {
                    procName = "sp_T_Planing_Action_SiteSurvey_Files_Delete";
                    foreach (var fileNo in obj.DeleteFiles.Split(','))
                    {
                        if (fileNo != "")
                        {
                            command = new SqlCommand(procName, conn, transaction);

                            command.CommandType = CommandType.StoredProcedure;
                            if (fileNo != null)
                            {
                                T_Planing_File file = new T_Planing_File();
                                file.PID      = PID;
                                file.No       = fileNo;
                                parameterList = new List <SqlParameter>();
                                parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                                command.Parameters.AddRange(parameterList.ToArray());
                                //  command.Parameters[0].Value = "";
                            }

                            command.ExecuteNonQuery();
                        }
                    }
                }


                procName = "sp_T_Planing_Action_SiteSurvey_Files_Insert";
                if (obj.UploadFileList != null && obj.UploadFileList.Count > 0)
                {
                    foreach (T_Planing_File file in obj.UploadFileList)
                    {
                        file.PID = PID;

                        command = new SqlCommand(procName, conn, transaction);

                        command.CommandType = CommandType.StoredProcedure;
                        if (file != null)
                        {
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                            //  command.Parameters[0].Value = "";
                        }

                        command.ExecuteNonQuery();
                    }
                }

                transaction.Commit();
            }
            catch (Exception ex)
            {
                isCan = false;
                transaction.Rollback();
                throw new Exception(ex.Message);
            }
            finally
            {
                CloseConnection();
            }
            return(isCan);
        }