Translate

Quick Book 2014 C# Voucher Posting And Get

Monday, March 14, 2016 Category : 0

Required : SDK 13.0
Download link : https://developer.intuit.com/docs/0250_qb/0020_get_set_up/sdk_downloads
https://developer.intuit.com/Downloads/Restricted?filename=qbsdk130.exe

Sample Experimental Project :
https://onedrive.live.com/redir?resid=7D3B49FB4453E77A!1431&authkey=!AANhtiemRiGCDwk&ithint=file%2crar


Reference Guide: 

http://www.nullskull.com/a/1568/c-net-application-with-quickbooks-desktop-edition.aspx
https://mukarrammukhtar.wordpress.com/quickbooks-with-net/
http://qbblog.ccrsoftware.info/2010/03/quickbooks-add-on-programs-sdk/

HTML FileBrowser Image Preview

Wednesday, February 3, 2016 Category : , , 0


HTML



<div class="form-group">
                                <label class="control-label col-md-3" for="inputWarning"> Image 1 </label>
                                <div class="col-md-4">
                                    <input id="exampleInputFile1" name="ImagePath" type="file">
                                    <b>Live Preview</b>
                                    <br />
                                    <div id="dvPreview1">
                                    </div>
                                </div>
                            </div>



Java Script




  window.onload = function () {

        LoadTempData();

        var fileBrowser = document.getElementById("exampleInputFile1");
        fileBrowser.onchange = function () {
            LoadImage('1', fileBrowser);
        }


        var fileBrowser2 = document.getElementById("exampleInputFile2");
        fileBrowser2.onchange = function () {
            LoadImage('2', fileBrowser2);
        }


        var fileBrowser3 = document.getElementById("exampleInputFile3");
        fileBrowser3.onchange = function () {
            LoadImage('3', fileBrowser3);
        }

        var fileBrowser4 = document.getElementById("exampleInputFile4");
        fileBrowser4.onchange = function () {
            LoadImage('4', fileBrowser4);
        }


        var fileBrowser5 = document.getElementById("exampleInputFile5");
        fileBrowser5.onchange = function () {
            LoadImage('5', fileBrowser5);
        }

    };





function LoadImage(idNo, fileBrowser)
    {

        if (typeof (FileReader) != "undefined") {
            var dvPreview = document.getElementById("dvPreview" + idNo);
            dvPreview.innerHTML = "";
            var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.jpg|.jpeg|.gif|.png|.bmp)$/;
            for (var i = 0; i < fileBrowser.files.length; i++) {
                var file = fileBrowser.files[i];
                if (regex.test(file.name.toLowerCase())) {
                    var reader = new FileReader();
                    reader.onload = function (e) {

                        //var img = document.createElement("IMG");
                        //img.height = "100";
                        //img.width = "100";
                        //img.src = e.target.result;
                        //dvPreview.appendChild(img);

                        var image = new Image();
                        image.src = e.target.result;
                        image.onload = function () {
                            if(image.width != 680 || image.height!=850)
                            {
                                alert('Image size not valid');

                                //debugger;
                                //fileBrowser.outerHTML = fileBrowser.outerHTML;
                                //$('#' + id).html($('#' + id).html());
                                fileBrowser.value = "";

                            } else {
                                image.height = "100";
                                image.width = "150";
                                //img.src = e.target.result;
                                dvPreview.appendChild(image);
                            }
                        };

                    }
                    reader.readAsDataURL(file);
                } else {
                    alert(file.name + " is not a valid image file.");
                    dvPreview.innerHTML = "";
                    return false;
                }
            }
        } else {
            alert("This browser does not support HTML10 FileReader.");
        }
    }


ASP.NET MVC Jquery Image and Text Save

Category : , 0




  $("#btnAdd").click(function (e) {
        e.preventDefault();
        //$("#form1").submit();
        var file1;
        if (document.getElementById("exampleInputFile1").files.length > 0)
            file1 = document.getElementById("exampleInputFile1").files[0];

        var file2;
        if (document.getElementById("exampleInputFile2").files.length > 0)
            file2 = document.getElementById("exampleInputFile2").files[0];


        var file3;
        if (document.getElementById("exampleInputFile3").files.length > 0)
            file3 = document.getElementById("exampleInputFile3").files[0];

        var file4;
        if (document.getElementById("exampleInputFile4").files.length > 0)
            file4 = document.getElementById("exampleInputFile4").files[0];

        var file5;
        if (document.getElementById("exampleInputFile5").files.length > 0)
            file5 = document.getElementById("exampleInputFile5").files[0];
      

        var formData = new FormData();
        formData.append("MainGroupId", $("#MainGroup").val());
        formData.append("MainGroupName", $("#MainGroup option:selected").text());

        formData.append("SubGroupId", $("#SubGroup").val());
        formData.append("SubGroupName", $("#SubGroup option:selected").text());

        formData.append("NewBrandId", $("#NewBrandId").val());
        formData.append("NewBrandName", $("#NewBrandId option:selected").text());

        formData.append("NewCategoryId", $("#NewCategoryId").val());
        formData.append("NewCategoryName", $("#NewCategoryId option:selected").text());

        formData.append("NewColorId", $("#NewColorId").val());
        formData.append("NewColorName", $("#NewColorId option:selected").text());

        formData.append("IsActive", $("#IsActive").val());
        formData.append("Description", $("#Description").val());

        formData.append("Image1", file1);
        formData.append("Image2", file2);
        formData.append("Image3", file3);
        formData.append("Image4", file4);
        formData.append("Image5", file5);

        formData.append("OperationType", $("#hdnType").val());

        $.ajax({
            type: "POST",
            url: _urlBase + '/ProductManage/AddTempProduct',
            data: formData,
            dataType: 'json',
            contentType: false,
            processData: false,
            success: function (data) {

                if (data.ResultState == true) {
                    // done
                }
                else if (data.ResultState == false)
                    ShowMessage(data.SqlError);

            },
            error: function (error) {
                alert("errror");
            }
        });

    });





Backend C# code


[HttpPost]
        public JsonResult AddTempProduct()
        {
            Result r = new Result();
            try
            {
                ArticlePOCO article = new ArticlePOCO();


                article.MainGroupId = Request.Form["MainGroupId"];
               

                string OperationType = Request.Form["OperationType"];

                
    if (Request.Files.Count > 0)
                    {
                        if (Request.Files["Image1"] != null)
                        {
                            article.Image1 = Request.Files["Image1"];
                        }
                        if (Request.Files["Image2"] != null)
                        {
                            article.Image2 = Request.Files["Image2"];
                        }
                        if (Request.Files["Image3"] != null)
                        {
                            article.Image3 = Request.Files["Image3"];
                        }
                        if (Request.Files["Image4"] != null)
                        {
                            article.Image4 = Request.Files["Image4"];
                        }
                        if (Request.Files["Image5"] != null)
                        {
                            article.Image5 = Request.Files["Image5"];
                        }
                    }
     
                

                
            }
            catch (Exception ex)
            {
                r.ResultState = false;
                r.SqlError = ex.Message;
            }

            System.Web.Mvc.JsonResult jsonRe = new System.Web.Mvc.JsonResult()
            {
                Data = r,
                JsonRequestBehavior = System.Web.Mvc.JsonRequestBehavior.DenyGet
            };

            return jsonRe;

        }

ASP.NET Ajax Control Calenter Extender CSS

Monday, February 1, 2016 Category : 0

Some time outer table class poperty change the calender style , then we can fix it by applying this css.





.ajax__calendar table
{
margin:0px !important;
width:auto !important;
padding-left:0px !important;

}

.ajax__calendar table td
{
padding-left:2px !important;
padding-right:2px !important;
width:auto !important;
}
.ajax__calendar table th
{
padding-left:0px !important;
width:auto !important;
}
.ajax__calendar_container table
{
margin:0px !important;
padding:0px !important;
}

C# SQL Connection Best Connection Practice

Sunday, January 17, 2016 0


namespace Repository
{
    public class SQLRepository
    {

        DbConnector dbCon = new DbConnector();

        #region Query Execute
        public Result ExecuteQuery(string SQL)
        {
            Result oResult = new Result();
            SqlCommand oCmd = null;

            try
            {

                if (dbCon.Connect != null)
                {
                    dbCon.OpenConnection();
                    oCmd = new SqlCommand(SQL, dbCon.Connect);
                    oCmd.ExecuteNonQuery();
                    oResult.ResultState = true;
                }
            }
            catch (Exception ex)
            {
                oResult.ResultState = false;
                oResult.SqlError = ex.Message;
            }
            finally
            {
                dbCon.CloseConnection();
            }
            return oResult;
        }

        public Result ExecuteQuery(List SQL)
        {
            Result oResult = new Result();
            SqlTransaction oTransaction = null;
            SqlCommand oCmd = null;

            try
            {

                if (dbCon.Connect != null)
                {
                    dbCon.OpenConnection();
                    oTransaction = dbCon.Connect.BeginTransaction();
                    foreach (string s in SQL)
                    {
                        oCmd = new SqlCommand(s, dbCon.Connect);
                        oCmd.Transaction = oTransaction;
                        oCmd.ExecuteNonQuery();
                        oResult.ResultState = true;
                    }
                    oTransaction.Commit();
                }
            }
            catch (Exception ex)
            {
                oResult.ResultState = false;
                oResult.SqlError = ex.Message;
                if (oTransaction != null)
                    oTransaction.Rollback();
            }
            finally
            {
                dbCon.CloseConnection();
            }
            return oResult;
        }

        public Result ExecuteQueryParam(List SQL)
        {
            Result oResult = new Result();
            SqlTransaction oTransaction = null;
            SqlCommand oCmd = null;

            try
            {

                if (dbCon.Connect != null)
                {
                    dbCon.OpenConnection();
                    oTransaction = dbCon.Connect.BeginTransaction();
                    foreach (SQLQuery s in SQL)
                    {
                        oCmd = new SqlCommand(s.sql, dbCon.Connect);
                        oCmd.Transaction = oTransaction;

                        foreach (SQLParam param in s.Param)
                        {
                            SqlParameter picparameter = new SqlParameter();
                            picparameter.SqlDbType = param.DbType; //SqlDbType.Image;
                            picparameter.ParameterName = param.ParamName; //"@PIC";
                            picparameter.Value = param.ParamValue;
                            oCmd.Parameters.Add(picparameter);
                        }

                        oCmd.ExecuteNonQuery();
                        oResult.ResultState = true;
                    }
                    oTransaction.Commit();
                }
            }
            catch (Exception ex)
            {
                oResult.ResultState = false;
                oResult.SqlError = ex.Message;
                if (oTransaction != null)
                    oTransaction.Rollback();
            }
            finally
            {
                dbCon.CloseConnection();
            }
            return oResult;
        }

        #endregion

        public Result Select(string SQL)
        {
            Result oResult = new Result();
            SqlCommand oCmd = null;
            try
            {

                if (dbCon.Connect != null)
                {
                    oCmd = new SqlCommand(SQL, dbCon.Connect);
                    oCmd.CommandTimeout = 0;
                    SqlDataAdapter adapter = new SqlDataAdapter(oCmd);
                    DataTable dt = new DataTable();
                    adapter.Fill(dt);
                    oResult.ResultState = true;
                    oResult.Data = dt;
                }
            }
            catch (Exception ex)
            {
                oResult.ResultState = false;
                oResult.SqlError = ex.Message;
            }
            finally
            {
                dbCon.CloseConnection();
            }
            return oResult;
        }

    }

    public class DbConnector
    {

        private SqlConnection connection;

        public DbConnector()
        {
            connection = new SqlConnection(GlobalConnection());
        }

        public string GlobalConnection()
        {

            //string entityConnectionString = ConfigurationManager.ConnectionStrings["ERPEntities"].ConnectionString;
            //string providerConnectionString = new EntityConnectionStringBuilder(entityConnectionString).ProviderConnectionString;
            //return providerConnectionString;

            string str = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
            //ConfigurationSettings.AppSettings["CNN"];
            return str;
        }

        public SqlConnection Connect
        {
            get { return connection; }
        }

        public ConnectionState OpenConnection()
        {
            Connect.Open();
            return ConnectionState.Open;
        }

        public ConnectionState CloseConnection()
        {
            Connect.Close();
            return ConnectionState.Closed;
        }
    }

    public class SQLQuery
    {
        public string sql { get; set; }
        public List Param = new List();
    }

    public class SQLParam
    {
        public string ParamName { get; set; }
        public byte[] ParamValue { get; set; }
        public SqlDbType DbType { get; set; }
    }

    //public class Result
    //{
    //    public bool ResultState;
    //    public string SqlError;
    //    public DataTable Data;
    //}

}


ASP.NET Page Close Confirmation

Friday, October 23, 2015 Category : 0

triggering closing X browser event

 

 

 <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>


    <script type="text/javascript">
        function OnBeforeUnLoadPage() {
            if (document.getElementById('hdnRefresh').value == "") {
                var result = confirm('Are you sure you want to navigate?');
                if (result) {
                    UnLoadPage();
                }
                else {
                    return false;
                }
            }
        }
        function DetectRefreshKey() {
            if (event.keyCode == 116) {
                document.getElementById('hdnRefresh').value = "1";
            }
        }
        function UnLoadPage() {
            PageMethods.ClearSession();
        }
        function DetachBodyUnload() {
            document.body.onbeforeunload = null;
            document.body.onunload = null;
        }
    </script>



</head>
<body onbeforeunload="return OnBeforeUnLoadPage(); " onkeypress="DetectRefreshKey();">
    <form id="form1" runat="server">
    <input type="hidden" id="hdnRefresh" />
    <asp:ScriptManager ID="sc" runat="server" EnablePageMethods="true" EnablePartialRendering="true">
    </asp:ScriptManager>
    <asp:Button ID="btnTest" runat="server" Text="Refresh" OnClientClick="DetachBodyUnload();"
        OnClick="btnTest_Click" />
    </form>
</body>

</html>




code behind:

protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext.Current.Session["test"] = "TEST DATA";
        }
        [WebMethod]
        public static void ClearSession()
        {
            HttpContext.Current.Session.Remove("test");
        }
        protected void btnTest_Click(object sender, EventArgs e)
        {           
        }





http://forums.asp.net/t/1580541.aspx

SQL SERVER – Attach mdf file without ldf file in Database

Tuesday, October 13, 2015 Category : 2


USE [master]
GO
-- Method 1: I use this method
EXEC sp_attach_single_file_db @dbname='TestDb',
@physname=N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf'
GO



-- Method 2:

CREATE DATABASE TestDb ON
(FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf')
FOR ATTACH_REBUILD_LOG
GO


-- Method 3:
CREATE DATABASE TestDb ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf')
FOR ATTACH
GO 




 Source : http://blog.sqlauthority.com/2010/04/26/sql-server-attach-mdf-file-without-ldf-file-in-database/



Exception case when fail to attach database and get such error like



"The log cannot be rebuilt because there were open transactions/users when the database was shutdown, no checkpoint occurred to the database, or the database was read-only. This error could occur if the transaction log file was manually deleted or lost due to a hardware or environment failure."  





Attaching the Damaged SQL Server Database

USE [master]
GO

CREATE DATABASE [TestDB_Repair]
 CONTAINMENT = NONE
 ON  PRIMARY
( NAME = N'TestDB_Repair_file1',
   FILENAME = N'E:\MSSQL\TestDB_Repair_1.mdf',
   SIZE = 8MB ,
   MAXSIZE = UNLIMITED,
   FILEGROWTH = 64MB)
 LOG ON
( NAME = N'TestDB_Repair_log_file1',
    FILENAME = N'E:\MSSQL\TestDB_Repair_1.ldf',
    SIZE = 8MB,
    MAXSIZE = 2048GB,
    FILEGROWTH = 32MB)


 Now we set the database offline.


USE master
GO

ALTER DATABASE [TestDB_Repair] SET OFFLINE WITH ROLLBACK IMMEDIATE
GO

At this point we can change the file location of our new database to point to our orphaned mdf file and set the location of the log file to a non-existent file.



USE master
GO

ALTER DATABASE [TestDB_Repair] MODIFY FILE(NAME='TestDB_Repair_file1', FILENAME= 'E:\MSSQL\TestDBCopy.mdf')
ALTER DATABASE [TestDB_Repair] MODIFY FILE(NAME='TestDB_Repair_log_file1', FILENAME= 'E:\MSSQL\TestDBCopy.ldf')
GO

Let’s bring the database back online.



USE master
GO

ALTER DATABASE [TestDB_Repair] SET ONLINE
GO





 

 

Rebuilding the SQL Server Transaction Log

USE master
GO

DBCC TRACEON(3604)
GO

ALTER DATABASE TestDB_Repair SET EMERGENCY
GO

ALTER DATABASE TestDB_Repair SET SINGLE_USER
GO

DBCC CHECKDB('TestDB_Repair', REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS
GO

ALTER DATABASE TestDB_Repair SET MULTI_USER
GO

 

Source : https://www.mssqltips.com/sqlservertip/3579/how-to-attach-a-sql-server-database-without-a-transaction-log-and-with-open-transactions/



Powered by Blogger.