示例#1
0
        public void Test_CreateSqlFormatter_AlternateConstructor_SQLServer()
        {
            //---------------Set up test pack-------------------
            string connectionString =
                new DatabaseConfig(DatabaseConfig.SqlServer, "test", "test", "test", "test", "1000").GetConnectionString
                    ();
            IDatabaseConnection dbConn = new DatabaseConnectionSqlServer
                                             ("System.Data", "System.Data.SqlClient.SqlConnection", connectionString);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ISqlFormatter defaultSqlFormatter = dbConn.SqlFormatter;

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(SqlFormatter), defaultSqlFormatter);
            SqlFormatter sqlFormatter = (SqlFormatter)defaultSqlFormatter;

            Assert.IsNotNull(sqlFormatter);
            Assert.AreEqual("[", sqlFormatter.LeftFieldDelimiter);
            Assert.AreEqual("]", sqlFormatter.RightFieldDelimiter);
            Assert.AreEqual("TOP", sqlFormatter.LimitClauseAtBeginning);
            Assert.AreEqual("", sqlFormatter.LimitClauseAtEnd);
            Assert.AreEqual("[", dbConn.LeftFieldDelimiter);
            Assert.AreEqual("]", dbConn.RightFieldDelimiter);
            //            StringAssert.Contains("TOP", dbConn.GetLimitClauseForBeginning(1));
            //            Assert.AreEqual("", dbConn.GetLimitClauseForEnd(1));
        }
示例#2
0
        public void Test_IsolationLevel_SqlServer()
        {
            //---------------Execute Test ----------------------
            DatabaseConnection conn =
                new DatabaseConnectionSqlServer("System.Data", "System.Data.SqlClient.SqlConnection");

            //---------------Test Result -----------------------
            Assert.AreEqual(IsolationLevel.ReadUncommitted, conn.IsolationLevel);
        }
示例#3
0
        public void Test_CreateDatabaseConnection_SqlServer()
        {
            DatabaseConnection conn = new DatabaseConnectionSqlServer
                                          ("System.Data", "System.Data.SqlClient.SqlConnection");

            conn.ConnectionString =
                new DatabaseConfig(DatabaseConfig.SqlServer, "test", "test", "test", "test", "1000").GetConnectionString
                    ();
            Assert.AreEqual
                ("System.Data.SqlClient", conn.TestConnection.GetType().Namespace,
                "Namespace of Sql connection is wrong.");
        }
        public void TestCreateParameterNameGenerator()
        {
            //---------------Set up test pack-------------------
            var databaseConnection = new DatabaseConnectionSqlServer("", "");
            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            var generator = databaseConnection.CreateParameterNameGenerator();

            //---------------Test Result -----------------------
            Assert.AreEqual("@", generator.PrefixCharacter);
            //---------------Tear Down -------------------------
        }
示例#5
0
        public string SaveProject(clsProjectMaster ProjectMaster, string notify)
        {
            string msg         = "";
            int    nextDocNo   = 0;
            string FormattedNo = "";

            string CompanyLink = HttpContext.Current.Request.Cookies["CompanyLink"].Value.ToString();

            // PROJECT OBJECT
            clsProjectMaster obj = ProjectMaster;

            obj.IsDeactivate = false;
            obj.CompanyLink  = HttpContext.Current.Request.Cookies["CompanyLink"].Value;
            obj.AreaLink     = DatabaseConnectionSqlServer.ExecuteScalarInternal("Select Link from AreaMaster where areamaster.isdeactivate=0 and areamaster.name Like '%" + obj.City + "%'");

            // LINK 0 THEN INSERT ELSE UPDATE RECORD
            if (obj.Link == 0)
            {
                DataTable dtNext = clsMethods.GetDocNo("PR");
                if (dtNext.Rows.Count > 0)
                {
                    // GET NEXT CUSTOMER NUMBER , NUMBER WILL BE LIKE THIS : PR00001
                    nextDocNo   = Convert.ToInt32(dtNext.Rows[0]["Next_Doc_No"].ToString());
                    FormattedNo = clsMethods.FormatDocumentNo("PR", Convert.ToDecimal(nextDocNo));
                }
                obj.ProjectNo = FormattedNo;

                // CREATED BY , CREATED HOST NAME, DATE OF CREATION FOR ALL THE RECORD WHICH IS INSERT FOR ALL TABLE
                obj.CreatedBy       = Convert.ToInt32(HttpContext.Current.Request.Cookies["UserId"].Value);
                obj.CreatedHostName = HttpContext.Current.Request.UserHostName;
                obj.DateOfCreation  = DateTime.Now;
            }
            else
            {
                // MODIFIED BY , MODIFIED HOST , MODIFIED DATE WHEN RECORD UPDATE.
                obj.ModifiedBy         = Convert.ToInt32(HttpContext.Current.Request.Cookies["UserId"].Value);
                obj.ModifiedHostName   = HttpContext.Current.Request.UserHostName;
                obj.DateOfModification = DateTime.Now;
            }

            clsIFrameWork.SetIndependentTable(obj);

            if (notify == "1")
            {
                // SEND MAIL
                DataTable dtEmail = DatabaseConnectionSqlServer.GetDataTable("Select Email from UserMaster where usermaster.Link = " + obj.SalesRepresentive);
                if (dtEmail.Rows.Count > 0)
                {
                    string Email = dtEmail.Rows[0]["Email"].ToString();
                    bool   mail  = clsMethods.SendMail("Project Creation", obj.InitialRequirement, Email, CompanyLink);
                }
            }


            bool issucc = false;

            try
            {
                // TRACACTION IS EXECUTE , SO ABOVE CREATED ALL QUERY WILL EXECUTE AT SAME TIME.
                issucc = clsIFrameWork.FireTransaction();
            }
            catch (Exception ex)
            {
                // ERROR LOG
                FileStream fs = new FileStream(ServerLogFile, FileMode.Append, FileAccess.Write, FileShare.Write);
                fs.Close();
                StreamWriter sw = new StreamWriter(ServerLogFile, true, Encoding.ASCII);
                sw.WriteLine(ex.ToString() + System.DateTime.Now.ToString());
                sw.Close();
                msg = ex.Message;
            }
            return(msg);
        }