Tuesday, December 31, 2019

Datatable to excel Download

public static void ExcelPrintWithSubReport(string SpName, DataTable dataSource)
        {

            GridView gv = new GridView();
            gv.DataSource = dataSource;
            gv.DataBind();

            SpName = SpName + ".xls";

            HttpContext context = System.Web.HttpContext.Current;
            context.Response.ClearContent();
            context.Response.Buffer = true;
            context.Response.AddHeader("content-disposition", "attachment; filename= CheckData.xls");
            context.Response.ContentType = "application/ms-excel";
            context.Response.Charset = "";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            gv.RenderControl(htw);
            context.Response.Output.Write(sw.ToString());
            context.Response.Flush();
            htw.Close();
            sw.Close();
            context.Response.End();

        }// End of Method

Delete Data From Joining Tables

Delete ev   FROM Evaluation AS ev
Inner Join Employee AS e ON ev.EmployeeId = e.EmployeeId
 WHERE
 e.OfficeId IN ( SELECT OfficeId FROM Office WHERE ThirdLevel = 2790 AND IsActive = 1 )
 AND ev.Year = 2019
 AND ev.EvaluationPeriodShort = 'D'

Sunday, November 10, 2019

SMS Count Function

--SELECT SUBSTRING('SQL Tutorial', 1, 100) AS ExtractString;   
   
-- SELECT dbo.CountSMS('HELLOJINIENENENENEE E E E E E  E EJENJDNEJDNE E EJDNENEF E EJNEF HELLOJINIENENENENEE E E E E E  E EJENJDNEJDNE E EJDNENEF E EJNEF HELLOJINIENENENENEE E E E E E  E EJENJDNEJDNE E EJDNENEF E EJNEF')   
CREATE FUNCTION CountSMS(@StringName nvarchar(1000))   
RETURNS int   
AS   
BEGIN   
--Declare @StringName nvarchar(50);   
Declare @initialLen int;   
Declare @WithFraction decimal(18,2);   
Declare @WithoutFraction int; 
Declare @smsCount int;   
   
SET @WithFraction = 0.00;   
SET @smsCount = 1;   
   
SET @initialLen = (SELECT len(@StringName));   
   
SET @WithFraction = @initialLen / 70.00;   
SET @WithoutFraction = @WithFraction 
   
IF(@WithFraction > @WithoutFraction)   --(@WithFraction < 1.00 AND @WithFraction > 0.00)   
BEGIN   
SET @smsCount = @WithoutFraction + 1;   
END   
ELSE   
BEGIN   
SET @smsCount = ROUND(@WithFraction,0);   
END   
   
   
   RETURN @smsCount   
   
 END   
   
-- SELECT SUBSTRING('SQL Tutorial', 1,1) AS ExtractString;

Monday, November 4, 2019

SQL FUNCTION Convert Numeric value to bangla.

--SELECT SUBSTRING('SQL Tutorial', 1, 100) AS ExtractString;

-- SELECT dbo.ConvertToBangla(12456.9087)
ALTER FUNCTION ConvertToBangla(@StringName nvarchar(50))
RETURNS NVARCHAR(50)
AS
BEGIN

--Declare @StringName nvarchar(50);
Declare @FinalString nvarchar(50);
Declare @FinalString2 nvarchar(50);

Declare @SingleCharacter nvarchar(1);
Declare @len int;
Declare @Templen int;

--SET @StringName = '8767564.89780';
SET @FinalString = N'';
SET @len = (SELECT LEN(@StringName));
SET @Templen = 1;
--SELECT @len

 WHILE @Templen <= @len
BEGIN
  SELECT @SingleCharacter = SUBSTRING(@StringName, @Templen,1)
 
    --SELECT  @SingleCharacter;
 
   SELECT @FinalString2 =
   CASE
    WHEN @SingleCharacter = '1' THEN N'১'
    WHEN @SingleCharacter = '2' THEN N'২'
    WHEN @SingleCharacter = '3' THEN N'৩'
WHEN @SingleCharacter = '4' THEN N'৪'
WHEN @SingleCharacter = '5' THEN N'৫'
WHEN @SingleCharacter = '6' THEN N'৬'
WHEN @SingleCharacter = '7' THEN N'৭'
WHEN @SingleCharacter = '8' THEN N'৮'
WHEN @SingleCharacter = '9' THEN N'৯'
WHEN @SingleCharacter = '0' THEN N'০'
WHEN @SingleCharacter = '.' THEN N'.'
    ELSE N''
END
--SELECT @FinalString2;

SET @FinalString = @FinalString + @FinalString2

SET @Templen = @Templen + 1;

END;

   --SELECT @FinalString;
   RETURN @FinalString
 
 END

-- SELECT SUBSTRING('SQL Tutorial', 1,1) AS ExtractString;

Sunday, October 20, 2019

Export Table to other Server: SQL SERVER


STEP 1: Right Click on Source database. Here you will see some Options. 

  Click on Export data.

STEP 2: A wizard will open. click on next button.


STEP 3:  Here the Source Of data need to choose. Give the credentials and select the database.


STEP 4: Continued of step 3. Choose the Source database.



STEP 5: In this step you have to choose the destination database. Give the credentials and select the database.


STEP 6: In this step the table need to choose. From which the data will be transfer. Notice the right side is the table name which will be on the destination server.




STEP 7: Keep Click on next.



STEP 8: Here the process will be started.


STEP 9: After the process is done this screen will be showed. click on close.


Now go to the destination database server. Execute: Select * FROM theTableName

Wednesday, October 2, 2019

My Work::KHALID

: Xamarin App Development
: R&D on new technologies
: File Management Systems
: gHRM New Features ; Rich text box, New Reports , Process on sql server side.
: gBanker : R&D: Add rich text Box, Using Ajax: On Select Member Show Photo and Signature.
: SMS: gHRM and gBanker New Module.
: Voice Data collection : Hisab.
: gHRM plus Attendence system and Time Picker add.
: digital signature add. Canvas to Crystal report.

Monday, September 30, 2019

Show image using ajax call



I created a service to get member information using entity framework.

then i used the service like this.

 [HttpGet]
        public JsonResult GetMemberImageData(string MemberId)
        {
            try
            {
  var memberPhoto = memberService.GetById(Convert.ToInt32(MemberId));

MemberViewModel myMember = new MemberViewModel();
myMember.MemberCode = Convert.ToBase64String( memberPhoto.MemberImg );

 List<MemberViewModel> List_ViewModel = new List<MemberViewModel>();

                List_ViewModel.Add(myMember);


  return Json(List_ViewModel.ToList(), JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            { return Json(ex.ToString(), JsonRequestBehavior.AllowGet); }

        }



in view:  .cshtml file::
function GetMemberPhotoSignature(member)
    {
        //alert(member);

         $.ajax({
            type: 'GET',
            contentType: "application/json; charset=utf-8",
            url: '@Url.Action("GetMemberImageData", "SpecialSavingCollection", "http")',
             data: { MemberId: member },
            dataType: 'json',
            async: true,
            success: function (data) {
                $('#AjaxLoader').hide();
                $.each(data, function (index, data) {
                    if (data != "Error") {
                        alert(data.MemberCode);
                        $("#target").attr("src", "data:image/gif;base64, " + data.MemberCode);
                            //$("#EmployeeID").val(data.EmployeeID);
                    }
                    else {
                       
                       // $("#EmployeeName").val('');
                    }
                });
            },
            error: function (request, status, error) {
                $('#AjaxLoader').hide();
             
               // $.alert.open("Employee Does Not Exist");
            }
        });




HTML::
<img id="target" src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
 AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
 9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />






Screen Record

 Windows Screen Record WindowsKey+ Alt + R Recording Starts.