public string GetColumnValueOfDBObjectForApp(SqlTransaction objTransaction, List <string> tableColumn, int pCompanyCode)
        {
            string vResult     = string.Empty;
            string vComText    = string.Empty;
            string vValue      = string.Empty;
            string vColumnName = tableColumn[1];
            string vTableName  = tableColumn[0];

            if (tableColumn.Count > 2)
            {
                vValue = tableColumn[2];
            }
            string tempStr = string.Empty;

            if (tableColumn != null && tableColumn.Count > 0)
            {
                vComText = @" SELECT TOP 1 " + vColumnName + " FROM " + vTableName + " WITH (TABLOCKX) WHERE " + vColumnName + " LIKE'" + vValue + "%' and companycode=" + pCompanyCode + "  Order BY " + vColumnName + " DESC";
            }
            SqlDataReader dr;
            SqlCommand    cmd = _supplierDbContext.GetCommand();

            cmd.CommandType    = System.Data.CommandType.Text;
            cmd.CommandText    = vComText;
            cmd.Transaction    = objTransaction;
            cmd.CommandTimeout = 60000;
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                vResult = dr[0].ToString();
            }
            dr.Close();

            return(vResult);
        }
        public string SaveRFPProcessing(RFProcessing objRFProcessing)
        {
            int       vResult         = 0;
            int       vApprovalResult = 0;
            string    vOut            = "Exception Occured !";
            ArrayList vQueryList      = new ArrayList();

            objRFProcessing.TableName_TBL = PMS_RFProcessing_TBL;
            SqlConnection connection = _supplierDbContext.GetConn();

            connection.Open();
            using (SqlTransaction trans = connection.BeginTransaction())
            {
                if (string.IsNullOrEmpty(objRFProcessing.RFProcessCode_PK))
                {
                    objRFProcessing.RFProcessCode_PK = Guid.NewGuid().ToString();
                    objRFProcessing.RFProcessId      = _iIDGenCriteriaInfo.GenerateID(trans, objRFProcessing, EnumIdCategory.RFPProcessing);
                }
                vQueryList.Add(GetQuery(objRFProcessing));

                try
                {
                    using (SqlCommand command = _supplierDbContext.GetCommand())
                    {
                        foreach (string obj_temp in vQueryList)
                        {
                            command.CommandText = obj_temp;
                            vResult             = command.ExecuteNonQuery();
                        }
                    }
                    if (vResult > 0)
                    {
                        vApprovalResult = AppObjectInfoMapDC.GenerateApprovalFromOtherObject(30, objRFProcessing.RFProcessCode_PK, objRFProcessing.UserCode, objRFProcessing.CompanyCode_FK, connection, trans);
                        if (vApprovalResult > 0)
                        {
                            trans.Commit();
                            vOut = "RFP Saved Successfully";
                        }
                    }
                }
                catch (DbException ex)
                {
                    trans.Rollback();
                    throw ex;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(vOut);
        }
Exemple #3
0
        public string SaveGeneralCodeFileType(GeneralCodeFileType objGeneralCodeFileType)
        {
            int       vResult    = 0;
            string    vOut       = "Exception Occured !";
            ArrayList vQueryList = new ArrayList();

            objGeneralCodeFileType.TableName_TBL = GeneralCodeFileType_TBL;
            SqlConnection connection = _supplierDbContext.GetConn();

            connection.Open();


            using (SqlTransaction trans = connection.BeginTransaction())
            {
                vQueryList.Add(GetQuery(objGeneralCodeFileType));

                try
                {
                    using (SqlCommand command = _supplierDbContext.GetCommand())
                    {
                        //command.Parameters.AddWithValue("FileTypeCode", objGeneralCodeFileType.FileTypeCode_PK);
                        foreach (string obj_temp in vQueryList)
                        {
                            command.CommandText = obj_temp;
                            command.Transaction = trans;
                            vResult             = command.ExecuteNonQuery();
                        }
                        if (vResult > 0)
                        {
                            trans.Commit();
                            vOut = "Code File Type Saved Successfully";
                        }
                        else
                        {
                            vOut = "File Type Code is duplicate";
                        }
                    }
                }
                catch (DbException ex)
                {
                    trans.Rollback();
                    throw ex;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(vOut);
        }
Exemple #4
0
        public string SavePurchaseOrder(PurchaseOrder objPurchaseOrder)
        {
            int       vResult    = 0;
            string    vOut       = "Exception Occured !";
            ArrayList vQueryList = new ArrayList();

            objPurchaseOrder.TableName_TBL = PurchaseOrder_TBL;
            SqlConnection connection = _supplierDbContext.GetConn();

            connection.Open();
            using (SqlTransaction trans = connection.BeginTransaction())
            {
                if (string.IsNullOrEmpty(objPurchaseOrder.PurchaseOrderCode_PK))
                {
                    objPurchaseOrder.PurchaseOrderCode_PK = Guid.NewGuid().ToString();
                    objPurchaseOrder.PurchaseOrderNo      = _iIDGenCriteriaInfo.GenerateID(trans, objPurchaseOrder, EnumIdCategory.PurchaseOrderNo);
                }
                vQueryList.Add(GetQuery(objPurchaseOrder));

                try
                {
                    using (SqlCommand command = _supplierDbContext.GetCommand())
                    {
                        foreach (string obj_temp in vQueryList)
                        {
                            command.CommandText = obj_temp;
                            vResult             = command.ExecuteNonQuery();
                        }
                    }
                    if (vResult > 0)
                    {
                        trans.Commit();
                        vOut = "Purchase Order Saved Successfully";
                    }
                }
                catch (DbException ex)
                {
                    trans.Rollback();
                    throw ex;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(vOut);
        }
        public string SaveProduct(Product objproduct)
        {
            int    vResult = 0;
            string vOut    = "Exception Occured !";

            objproduct.TableName_TBL = Product_TBL;
            string        vQuery     = string.Empty;
            SqlConnection connection = _supplierDbContext.GetConn();

            connection.Open();
            using (SqlTransaction trans = connection.BeginTransaction())
            {
                if (string.IsNullOrEmpty(objproduct.ProductCode_PK))
                {
                    objproduct.ProductCode_PK = Guid.NewGuid().ToString();
                    objproduct.ProductID      = _iIDGenCriteriaInfo.GenerateID(trans, objproduct, EnumIdCategory.ProductID);
                }
                vQuery = _cRUD.CREATEQuery(objproduct);
                try
                {
                    using (SqlCommand command = _supplierDbContext.GetCommand())
                    {
                        command.CommandText = vQuery;
                        vResult             = command.ExecuteNonQuery();
                    }
                    if (vResult > 0)
                    {
                        trans.Commit();
                        vOut = "Product Saved Successfully";
                    }
                }

                catch (DbException ex)
                {
                    trans.Rollback();
                    throw ex;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(vOut);
        }
        public string SaveGeneralCodeFile(GeneralCodeFile objGeneralCodeFile)
        {
            objGeneralCodeFile.TableName_TBL = GeneralCodeFile_TBL;
            ArrayList vQueryList = new ArrayList();
            string    vOut       = "Exception Occured !";
            int       vResult    = 0;
            int       count      = 0;
            int       count_nm   = 0;


            SqlConnection connection = _supplierDbContext.GetConn();

            connection.Open();

            using (SqlTransaction objDbTransaction = connection.BeginTransaction())
            {
                try
                {
                    // Query for checking duplicate FileCode
                    string vValidationQuery = @"select Count(FileCode)cnt_filecode from " + GeneralCodeFile_TBL + " where CompanyCode = 1 AND FileTypeCode=" + objGeneralCodeFile.FileTypeCode + " and FileId=" + objGeneralCodeFile.FileId + "";

                    // Query for checking duplicate name
                    string vCheckDuplicateQuery = "select count(FileCode)cnt_filename  from General_CodeFile where CompanyCode = 1 AND FileTypeCode=" + objGeneralCodeFile.FileTypeCode + "  and FileName='" + objGeneralCodeFile.FileName + "'";


                    if (string.IsNullOrEmpty(objGeneralCodeFile.ParentFileCode))
                    {
                        vValidationQuery = vValidationQuery + " and ParentFileCode is null";
                        // Query for checking duplicate FileName
                        vCheckDuplicateQuery = vCheckDuplicateQuery + " and ParentFileCode is null";
                    }
                    else
                    {
                        vValidationQuery = vValidationQuery + " and ParentFileCode =" + objGeneralCodeFile.ParentFileCode + "";
                        // Query for checking duplicate FileName
                        vCheckDuplicateQuery = vCheckDuplicateQuery + " and ParentFileCode =" + objGeneralCodeFile.ParentFileCode + "";
                    }
                    if (!objGeneralCodeFile.IsNew)
                    {
                        vValidationQuery     = vValidationQuery + " and FileCode!=@FileCode";
                        vCheckDuplicateQuery = vCheckDuplicateQuery + " and FileCode!=@FileCode";
                    }

                    SqlDataReader drCommandValidation;
                    //for checking duplicate FileCode
                    SqlCommand objDbCommandValidation = new SqlCommand(vValidationQuery, connection);

                    SqlDataReader drCommandCheck;
                    //for checking duplicate FileName
                    SqlCommand objDbCommandCheckDuplicate = new SqlCommand(vCheckDuplicateQuery, connection);


                    objDbCommandValidation.Parameters.AddWithValue("FileTypeCode", objGeneralCodeFile.FileTypeCode);
                    objDbCommandValidation.Parameters.AddWithValue("FileId", objGeneralCodeFile.FileId);

                    objDbCommandCheckDuplicate.Parameters.AddWithValue("FileTypeCode", objGeneralCodeFile.FileTypeCode);
                    objDbCommandCheckDuplicate.Parameters.AddWithValue("FileName", objGeneralCodeFile.FileName);

                    if (!string.IsNullOrEmpty(objGeneralCodeFile.ParentFileCode))
                    {
                        objDbCommandValidation.Parameters.AddWithValue("ParentFileCode", objGeneralCodeFile.ParentFileCode);
                        objDbCommandCheckDuplicate.Parameters.AddWithValue("ParentFileCode", objGeneralCodeFile.ParentFileCode);
                    }

                    if (!objGeneralCodeFile.IsNew)
                    {
                        objDbCommandValidation.Parameters.AddWithValue("FileCode", objGeneralCodeFile.FileCode_PK);
                        objDbCommandCheckDuplicate.Parameters.AddWithValue("FileCode", objGeneralCodeFile.FileCode_PK);
                    }

                    objDbCommandValidation.Transaction = objDbTransaction;
                    drCommandValidation = objDbCommandValidation.ExecuteReader();


                    if (drCommandValidation.Read())
                    {
                        //CommandValidationCount++;
                        count = Convert.ToUInt16(drCommandValidation["cnt_filecode"].ToString());
                    }

                    if (count > 0)
                    {
                        //connections.Close();
                        drCommandValidation.Close();
                        objDbTransaction.Rollback();
                        vOut = "Code is not unique within the scope";
                    }
                    else
                    {
                        drCommandValidation.Close();
                        objDbTransaction.Rollback();

                        using (SqlTransaction objDbTransactions = connection.BeginTransaction())
                        {
                            objDbCommandCheckDuplicate.Transaction = objDbTransactions;
                            drCommandCheck = objDbCommandCheckDuplicate.ExecuteReader();
                            //int CommandCheckCount = 0;
                            if (drCommandCheck.Read())
                            {
                                count_nm = Convert.ToUInt16(drCommandCheck["cnt_filename"].ToString());
                            }
                            if (count_nm > 0)
                            {
                                //connections.Close();
                                drCommandCheck.Close();
                                objDbTransactions.Rollback();
                                vOut = "Duplicate Name";
                            }
                            else
                            {
                                drCommandCheck.Close();
                                objDbTransactions.Rollback();

                                using (SqlTransaction trans = connection.BeginTransaction())
                                {
                                    string vComTxt = @"select isnull(max(FileCode),0) + 1  as FileCode_PK from General_CodeFile";

                                    //SqlConnection connection = _supplierDbContext.GetConn();
                                    //connection.Open();
                                    SqlDataReader dr;
                                    SqlCommand    objDbCommand = new SqlCommand(vComTxt, connection, trans);
                                    dr = objDbCommand.ExecuteReader();

                                    while (dr.Read())
                                    {
                                        objGeneralCodeFile.FileCode_PK = Convert.ToInt32(dr["FileCode_PK"].ToString());
                                    }
                                    objDbCommand.Dispose();
                                    //connections.Close();
                                    dr.Close();

                                    vQueryList.Add(GetQuery(objGeneralCodeFile));

                                    vResult = 0;


                                    //SqlConnection connectionn = _supplierDbContext.GetConn();
                                    //connectionn.Open();

                                    try
                                    {
                                        using (SqlCommand command = _supplierDbContext.GetCommand())
                                        {
                                            foreach (string obj_temp in vQueryList)
                                            {
                                                command.CommandText = obj_temp;
                                                command.Transaction = trans;
                                                vResult             = command.ExecuteNonQuery();
                                            }
                                            if (vResult > 0)
                                            {
                                                trans.Commit();
                                                vOut = "Records Saved.";
                                            }
                                            else
                                            {
                                                vOut = " 0 Records Saved.";
                                            }

                                            //if (vResult > 0 && string.IsNullOrEmpty(objGeneralCodeFile.ParentFileCode) && objGeneralCodeFile.FileTypeCode == 27)
                                            //{

                                            //}
                                        }
                                    }
                                    catch (DbException ex)
                                    {
                                        //connection.Close();
                                        //trans.Rollback();
                                        throw ex;
                                    }
                                    finally
                                    {
                                        connection.Close();
                                    }
                                    return(vOut);
                                }
                            }
                        }
                    }
                }
                catch (DbException ex)
                {
                    throw ex;
                }
                finally
                {
                    connection.Close();
                }
                return(vOut);
            }


            //using (SqlTransaction objDbTransaction = connections.BeginTransaction())
            //{
            //    // Query for checking duplicate FileCode
            //    string vValidationQuery = @"select Count(FileCode)cnt_filecode from " + GeneralCodeFile_TBL + " where CompanyCode = 1 AND FileTypeCode=" + objGeneralCodeFile.FileTypeCode + " and FileId=" + objGeneralCodeFile.FileId + "";

            //    // Query for checking duplicate name
            //    string vCheckDuplicateQuery = "select count(FileCode)cnt_filename  from General_CodeFile where CompanyCode = 1 AND FileTypeCode=" + objGeneralCodeFile.FileTypeCode + "  and FileName='" + objGeneralCodeFile.FileName + "'";


            //    if (string.IsNullOrEmpty(objGeneralCodeFile.ParentFileCode))
            //    {
            //        vValidationQuery = vValidationQuery + " and ParentFileCode is null";
            //        // Query for checking duplicate FileName
            //        vCheckDuplicateQuery = vCheckDuplicateQuery + " and ParentFileCode is null";
            //    }
            //    else
            //    {
            //        vValidationQuery = vValidationQuery + " and ParentFileCode =" + objGeneralCodeFile.ParentFileCode + "";
            //        // Query for checking duplicate FileName
            //        vCheckDuplicateQuery = vCheckDuplicateQuery + " and ParentFileCode =" + objGeneralCodeFile.ParentFileCode + "";
            //    }
            //    if (!objGeneralCodeFile.IsNew)
            //    {
            //        vValidationQuery = vValidationQuery + " and FileCode!=@FileCode";
            //        vCheckDuplicateQuery = vCheckDuplicateQuery + " and FileCode!=@FileCode";
            //    }

            //    SqlDataReader drCommandValidation;
            //    //for checking duplicate FileCode
            //    SqlCommand objDbCommandValidation = new SqlCommand(vValidationQuery, connections);


            //    SqlDataReader drCommandCheck;
            //    //for checking duplicate FileName
            //    SqlCommand objDbCommandCheckDuplicate = new SqlCommand(vCheckDuplicateQuery, connections);


            //    objDbCommandValidation.Parameters.AddWithValue("FileTypeCode", objGeneralCodeFile.FileTypeCode);
            //    objDbCommandValidation.Parameters.AddWithValue("FileId", objGeneralCodeFile.FileId);

            //    objDbCommandCheckDuplicate.Parameters.AddWithValue("FileTypeCode", objGeneralCodeFile.FileTypeCode);
            //    objDbCommandCheckDuplicate.Parameters.AddWithValue("FileName", objGeneralCodeFile.FileName);

            //    if (!string.IsNullOrEmpty(objGeneralCodeFile.ParentFileCode))
            //    {
            //        objDbCommandValidation.Parameters.AddWithValue("ParentFileCode", objGeneralCodeFile.ParentFileCode);
            //        objDbCommandCheckDuplicate.Parameters.AddWithValue("ParentFileCode", objGeneralCodeFile.ParentFileCode);
            //    }

            //    if (!objGeneralCodeFile.IsNew)
            //    {
            //        objDbCommandValidation.Parameters.AddWithValue("FileCode", objGeneralCodeFile.FileCode_PK);
            //        objDbCommandCheckDuplicate.Parameters.AddWithValue("FileCode", objGeneralCodeFile.FileCode_PK);
            //    }

            //    objDbCommandValidation.Transaction = objDbTransaction;
            //    drCommandValidation = objDbCommandValidation.ExecuteReader();
            //    //int CommandValidationCount = 0;

            //    if (drCommandValidation.Read())
            //    {
            //        //CommandValidationCount++;
            //        count = Convert.ToUInt16(drCommandValidation["cnt_filecode"].ToString());
            //    }
            //    if (count > 0)
            //    {
            //        //connections.Close();
            //        drCommandValidation.Close();
            //        objDbTransaction.Rollback();
            //        vOut = "Code is not unique within the scope";
            //    }
            //    else
            //    {
            //        drCommandValidation.Close();
            //        objDbTransaction.Rollback();
            //    }

            //    using (SqlTransaction objDbTransactions = connections.BeginTransaction())
            //    {
            //        objDbCommandCheckDuplicate.Transaction = objDbTransactions;
            //        drCommandCheck = objDbCommandCheckDuplicate.ExecuteReader();
            //        //int CommandCheckCount = 0;
            //        if (drCommandCheck.Read())
            //        {
            //            count_nm = Convert.ToUInt16(drCommandCheck["cnt_filename"].ToString());
            //        }
            //        if (count_nm > 0)
            //        {
            //            //connections.Close();
            //            drCommandCheck.Close();
            //            objDbTransactions.Rollback();
            //            vOut = "Duplicate Name";
            //        }
            //        else
            //        {
            //            drCommandCheck.Close();
            //            objDbTransactions.Rollback();
            //        }
            //    }


            //    using (SqlTransaction trans = connections.BeginTransaction())
            //    {
            //        string vComTxt = @"select isnull(max(FileCode),0) + 1  as FileCode_PK from General_CodeFile";

            //        //SqlConnection connection = _supplierDbContext.GetConn();
            //        //connection.Open();
            //        SqlDataReader dr;
            //        SqlCommand objDbCommand = new SqlCommand(vComTxt, connections, trans);
            //        dr = objDbCommand.ExecuteReader();

            //        while (dr.Read())
            //        {
            //            objGeneralCodeFile.FileCode_PK = Convert.ToInt32(dr["FileCode_PK"].ToString());
            //        }
            //        objDbCommand.Dispose();
            //        //connections.Close();
            //        dr.Close();

            //        vQueryList.Add(GetQuery(objGeneralCodeFile));

            //        vResult = 0;


            //        //SqlConnection connectionn = _supplierDbContext.GetConn();
            //        //connectionn.Open();

            //        try
            //        {
            //            using (SqlCommand command = _supplierDbContext.GetCommand())
            //            {
            //                foreach (string obj_temp in vQueryList)
            //                {

            //                    command.CommandText = obj_temp;
            //                    command.Transaction = trans;
            //                    vResult = command.ExecuteNonQuery();
            //                }
            //                if (vResult > 0)
            //                {
            //                    trans.Commit();
            //                    vOut = "Records Saved.";
            //                }
            //                else
            //                    vOut = " 0 Records Saved.";

            //                //if (vResult > 0 && string.IsNullOrEmpty(objGeneralCodeFile.ParentFileCode) && objGeneralCodeFile.FileTypeCode == 27)
            //                //{

            //                //}
            //            }
            //        }
            //        catch (DbException ex)
            //        {
            //            //connection.Close();
            //            //trans.Rollback();
            //            throw ex;

            //        }
            //        finally
            //        {
            //            connections.Close();
            //        }
            //        return vOut;
            //    }

            //}
        }
        public string SaveGeneralCodeFileLevel(GeneralCodeFileLevel objGeneralCodeFileLevel)
        {
            objGeneralCodeFileLevel.TableNm_TBL = GeneralCodeFileType_TBL;
            ArrayList vQueryList = new ArrayList();
            string    vOut       = "Exception Occured !";

            if (objGeneralCodeFileLevel.IsNew)
            {
                string vComTxt = @"select (isnull(max(LevelCode),0) +1) as LevelCode_PK from General_CodeFileLevel";

                SqlConnection connections = _supplierDbContext.GetConn();
                connections.Open();
                SqlDataReader dr;
                SqlCommand    objDbCommand = new SqlCommand(vComTxt, connections);
                dr = objDbCommand.ExecuteReader();

                while (dr.Read())
                {
                    objGeneralCodeFileLevel.LevelCode_PK = Convert.ToInt32(dr["LevelCode_PK"].ToString());
                }
                objDbCommand.Dispose();
                connections.Close();

                vQueryList.Add(GetQuery(objGeneralCodeFileLevel));

                int vResult = 0;


                SqlConnection connection = _supplierDbContext.GetConn();
                connection.Open();

                using (SqlTransaction trans = connection.BeginTransaction())
                {
                    try
                    {
                        using (SqlCommand command = _supplierDbContext.GetCommand())
                        {
                            foreach (string obj_temp in vQueryList)
                            {
                                command.CommandText = obj_temp;
                                command.Transaction = trans;
                                vResult             = command.ExecuteNonQuery();
                            }
                            if (vResult > 0)
                            {
                                trans.Commit();
                                vOut = "Code File Level Saved Successfully";
                            }
                            else
                            {
                                vOut = "Level Code is duplicate";
                            }
                        }
                    }
                    catch (DbException ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        connection.Close();
                    }
                }
            }
            return(vOut);
        }
        public string SaveApproverSelection(List <AppLevelDefDetAppType> objIAppLevelDefDetAppType_List)
        {
            int           vResult    = 0;
            string        vOut       = "Exception Occured !";
            SqlConnection connection = _supplierDbContext.GetConn();


            List <string> vQueryList = new List <string>();

            foreach (AppLevelDefDetAppType objIAppLevelDefDetAppType in objIAppLevelDefDetAppType_List)
            {
                objIAppLevelDefDetAppType.TableName_TBL = ObjAppLevelDefDetAppTypeTable;

                if (objIAppLevelDefDetAppType.IsNew)
                {
                    objIAppLevelDefDetAppType.ActionType = "CREATE";
                    vQueryList.Add(_CRUDBuilder.CREATEQuery(objIAppLevelDefDetAppType));
                }
                else
                {
                    if (objIAppLevelDefDetAppType.IsDeleted == false)
                    {
                        objIAppLevelDefDetAppType.ActionType = "UPDATE";
                    }
                    else
                    {
                        objIAppLevelDefDetAppType.ActionType = "DELETE";
                    }
                    vQueryList.Add(_CRUDBuilder.UPDATEQuery(objIAppLevelDefDetAppType));
                }

                foreach (AppLevelDetAppTypeApprover objIAppLevelDetAppTypeApprover in objIAppLevelDefDetAppType.objAppLevelDetAppTypeApproverList_VW)
                {
                    //details

                    objIAppLevelDetAppTypeApprover.TableName_TBL = ObjAppLevelDetAppTypeApproverTable;

                    if (objIAppLevelDetAppTypeApprover.IsNew)
                    {
                        objIAppLevelDetAppTypeApprover.ActionType = "CREATE";
                        vQueryList.Add(_CRUDBuilder.CREATEQuery(objIAppLevelDetAppTypeApprover));
                    }
                    else if (objIAppLevelDetAppTypeApprover.IsDeleted == false)
                    {
                        objIAppLevelDetAppTypeApprover.ActionType = "UPDATE";
                        vQueryList.Add(_CRUDBuilder.UPDATEQuery(objIAppLevelDetAppTypeApprover));
                    }
                    else
                    {
                        Hashtable pMarkDELColNameValues = new Hashtable();
                        pMarkDELColNameValues.Clear();
                        objIAppLevelDetAppTypeApprover.ActionType = "DELETE";
                        pMarkDELColNameValues.Add("ActionType", objIAppLevelDetAppTypeApprover.ActionType);
                        pMarkDELColNameValues.Add("ActionDate", objIAppLevelDetAppTypeApprover.ActionDate);
                        pMarkDELColNameValues.Add("UserCode", objIAppLevelDetAppTypeApprover.UserCode);
                        pMarkDELColNameValues.Add("CompanyCode", objIAppLevelDetAppTypeApprover.CompanyCode_FK);

                        vQueryList.Add(_CRUDBuilder.DELETEQuery(objIAppLevelDetAppTypeApprover, true, pMarkDELColNameValues));
                    }
                }
            }



            connection.Open();
            using (SqlTransaction trans = connection.BeginTransaction())
            {
                try
                {
                    using (SqlCommand command = _supplierDbContext.GetCommand())
                    {
                        if (vQueryList.Count > 0)
                        {
                            foreach (string obj_temp in vQueryList)
                            {
                                command.CommandText = obj_temp;
                                command.Transaction = trans;
                                vResult             = command.ExecuteNonQuery();
                                if (vResult < 1)
                                {
                                    trans.Rollback();
                                    vOut = "0 Records saved!";
                                    return(vOut);
                                }
                            }

                            trans.Commit();
                            vOut = "Information Saved Successfully";
                        }
                        else
                        {
                            trans.Rollback();
                            vOut = "0 Records saved!";
                        }
                    }
                }
                catch (DbException ex)
                {
                    trans.Rollback();
                    throw ex;
                }
                finally
                {
                    connection.Close();
                }
            }



            return(vOut);
        }
        public string SavePurchaseRequsition(PurchaseRequisition objPMS_PurchaseRequisition)
        {
            int       vResult         = 0;
            int       vApprovalResult = 0;
            string    vOut            = "Exception Occured !";
            ArrayList vQueryList      = new ArrayList();

            objPMS_PurchaseRequisition.TableName_TBL = PMS_PurchaseRequisition_TBL;
            SqlConnection connection = _supplierDbContext.GetConn();

            connection.Open();
            using (SqlTransaction trans = connection.BeginTransaction())
            {
                if (string.IsNullOrEmpty(objPMS_PurchaseRequisition.RequisitionCode_PK))
                {
                    objPMS_PurchaseRequisition.RequisitionCode_PK = Guid.NewGuid().ToString();
                    objPMS_PurchaseRequisition.RequisitionID      = _iIDGenCriteriaInfo.GenerateID(trans, objPMS_PurchaseRequisition, EnumIdCategory.PurchaseRequsition);
                }
                vQueryList.Add(GetQuery(objPMS_PurchaseRequisition));
                foreach (PurchaseRequisitionItem objPurchaseRequisitionItem in objPMS_PurchaseRequisition.PurchaseRequisitionItemList_VW)
                {
                    if (string.IsNullOrEmpty(objPurchaseRequisitionItem.RequisitionDetCode_PK))
                    {
                        objPurchaseRequisitionItem.RequisitionDetCode_PK = Guid.NewGuid().ToString();
                        objPurchaseRequisitionItem.TableName_TBL         = PMS_PurchaseRequisitionItem_TBL;
                        objPurchaseRequisitionItem.RequisitionCode       = objPMS_PurchaseRequisition.RequisitionCode_PK;
                    }
                    vQueryList.Add(GetQuery(objPurchaseRequisitionItem));
                    foreach (PurchaseReqItemSpecification objPurchaseReqItemSpecification in objPurchaseRequisitionItem.PurchaseReqItemSpecificationList_VW)
                    {
                        if (string.IsNullOrEmpty(objPurchaseReqItemSpecification.SpecificationCode_PK))
                        {
                            objPurchaseReqItemSpecification.SpecificationCode_PK = Guid.NewGuid().ToString();
                            objPurchaseReqItemSpecification.TableName_TBL        = PMS_PurchaseReqItemSpecification_TBL;
                            objPurchaseReqItemSpecification.RequisitionDetCode   = objPurchaseRequisitionItem.RequisitionDetCode_PK;
                        }
                        vQueryList.Add(GetQuery(objPurchaseReqItemSpecification));
                    }
                }
                foreach (PurchaseRequisitionCondition objPurchaseRequisitionTerms in objPMS_PurchaseRequisition.PurchaseRequisitionTermsList_VW)
                {
                    if (!string.IsNullOrEmpty(objPurchaseRequisitionTerms.ConditionCode_PK))
                    {
                        //objPurchaseRequisitionTerms.ConditionCode_PK = Guid.NewGuid().ToString();
                        objPurchaseRequisitionTerms.TableName_TBL   = PMS_RequisitionTermsCondition_TBL;
                        objPurchaseRequisitionTerms.RequisitionCode = objPMS_PurchaseRequisition.RequisitionCode_PK;
                    }
                    vQueryList.Add(GetQuery(objPurchaseRequisitionTerms));
                }
                try
                {
                    using (SqlCommand command = _supplierDbContext.GetCommand())
                    {
                        foreach (string obj_temp in vQueryList)
                        {
                            command.CommandText = obj_temp;
                            vResult             = command.ExecuteNonQuery();
                        }
                    }
                    if (vResult > 0)
                    {
                        vApprovalResult = AppObjectInfoMapDC.GenerateApprovalFromOtherObject(29, objPMS_PurchaseRequisition.RequisitionCode_PK, objPMS_PurchaseRequisition.UserCode, objPMS_PurchaseRequisition.CompanyCode_FK, connection, trans);
                        if (vApprovalResult > 0)
                        {
                            trans.Commit();
                            vOut = "Purchase Requsition Saved Successfully";
                        }
                    }
                }
                catch (DbException ex)
                {
                    trans.Rollback();
                    throw ex;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(vOut);
        }
Exemple #10
0
        public string SaveMappedBusinessObject(List <AppModuleObjectMapping> objIAppModuleObjectMappingList)
        {
            int           vResult    = 0;
            int           vResult1   = 0;
            string        vComTxt    = string.Empty;
            string        vOut       = "Exception Occured !";
            List <string> vQueryList = new List <string>();

            foreach (AppModuleObjectMapping objIApp in objIAppModuleObjectMappingList)
            {
                objIApp.TableName_TBL = "LS_AppModuleObjectMapping";


                if (objIApp.IsNew)
                {
                    objIApp.ModuleObjMapCode_PK = Guid.NewGuid().ToString();
                }
            }
            if (objIAppModuleObjectMappingList != null && objIAppModuleObjectMappingList.Count > 0)
            {
                for (int i = 0; i < objIAppModuleObjectMappingList.Count; i++)
                {
                    if (objIAppModuleObjectMappingList[i].IsNew == true && objIAppModuleObjectMappingList[i].IsDeleted == false)
                    {
                        vQueryList.Add(_cRUD.CREATEQuery(objIAppModuleObjectMappingList[i]));
                    }

                    else if (objIAppModuleObjectMappingList[i].IsNew == false && objIAppModuleObjectMappingList[i].IsDeleted == false)
                    {
                        vQueryList.Add(_cRUD.UPDATEQuery(objIAppModuleObjectMappingList[i]));
                    }
                    else if (objIAppModuleObjectMappingList[i].IsNew == false && objIAppModuleObjectMappingList[i].IsDeleted == true)
                    {
                        Hashtable pMarkDELColNameValues = new Hashtable();
                        pMarkDELColNameValues.Clear();
                        objIAppModuleObjectMappingList[i].ActionType = "DELETE";
                        pMarkDELColNameValues.Add("ActionType", objIAppModuleObjectMappingList[i].ActionType);
                        pMarkDELColNameValues.Add("ActionDate", objIAppModuleObjectMappingList[i].ActionDate);
                        pMarkDELColNameValues.Add("UserCode", objIAppModuleObjectMappingList[i].UserCode);
                        pMarkDELColNameValues.Add("CompanyCode", objIAppModuleObjectMappingList[i].CompanyCode_FK);

                        vQueryList.Add(_cRUD.DELETEQuery(objIAppModuleObjectMappingList[i], true, pMarkDELColNameValues));
                    }
                }
            }
            SqlConnection connection = _supplierDbContext.GetConn();

            connection.Open();
            using (SqlTransaction trans = connection.BeginTransaction())
            {
                try
                {
                    using (SqlCommand command = _supplierDbContext.GetCommand())
                    {
                        foreach (string obj_temp in vQueryList)
                        {
                            command.CommandText = obj_temp;
                            command.Transaction = trans;
                            vResult             = command.ExecuteNonQuery();
                        }
                        if (vResult > 0)
                        {
                            trans.Commit();
                            vOut = "Information Saved Successfully";
                        }
                    }
                }

                catch (DbException ex)
                {
                    trans.Rollback();
                    throw ex;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(vOut);
        }