Example #1
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    protected void imgbtnShowCalendar_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton ib = (ImageButton)sender;

        if (ib.ID == "imgbtnShowGCalendar")
        {
            ViewState["TypeSpecifiedDate"] = "G";
            ddlYears.Items.Clear();
            ddlMonths.Items.Clear();
            DateFun.PopulateGreYear(ref ddlYears);
            DateFun.PopulateGreMonth(ref ddlMonths);
        }
        else if (ib.ID == "imgbtnShowHCalendar")
        {
            ViewState["TypeSpecifiedDate"] = "H";
            ddlYears.Items.Clear();
            ddlMonths.Items.Clear();
            DateFun.PopulateHijYear(ref ddlYears);
            DateFun.PopulateHijMonth(ref ddlMonths);
        }

        Changedate(ViewState["TypeSpecifiedDate"].ToString());
        CssStyleCollection pnlCalendarStyle = this.pnlCalendar.Style;
        string             DISPLAY          = pnlCalendarStyle["DISPLAY"];

        if (DISPLAY == "none")
        {
            this.pnlCalendar.Attributes.Add("style", "POSITION: absolute");
        }
        else
        {
            this.pnlCalendar.Attributes.Add("style", "DISPLAY: none; POSITION: absolute");
        }
    }
Example #2
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    protected void BirthDateValidate_ServerValidate(Object source, ServerValidateEventArgs e)
    {
        try
        {
            if (source.Equals(cvcalBirthDate))
            {
                if (string.IsNullOrEmpty(CalBirthDate.getDate()))
                {
                    General.ValidMsg(this, ref cvcalBirthDate, false, "Birth Date is required", "تاريخ الميلاد مطلوب");
                    e.IsValid = false;
                    return;
                }
                else
                {
                    int iStartDate = DateFun.ConvertDateTimeToInt(FormSession.DateType, CalBirthDate.getDate());
                    int iEndDate   = DateFun.ConvertDateTimeToInt(FormSession.DateType, (DateFun.ToAnyFormat(FormSession.DateType, DateTime.Now)));
                    General.ValidMsg(this, ref cvcalBirthDate, true, "Birthday greater than today's date", "تاريخ الميلاد أكبر من تاريخ اليوم");

                    if (iStartDate > iEndDate)
                    {
                        e.IsValid = false;
                    }
                }
            }
        }
        catch { e.IsValid = false; }
    }
Example #3
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void setTodayDate()
    {
        try
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            string DType = "Gregorian";

            if (DateType == "S")
            {
                DType = Session["DateFormat"].ToString();
            }
            else if (DateType == "G")
            {
                DType = "Gregorian";
            }
            else if (DateType == "H")
            {
                DType = "Hijri";
            }

            this.txtType.Text = DateType;
            if (DType == "Gregorian")
            {
                this.txtDate.Text = String.Format("{0:dd/MM/yyyy}", DateTime.Now);
            }
            if (DType == "Hijri")
            {
                this.txtDate.Text = DateFun.GrnToHij(DateTime.Now).ToString();
            }
        }
        catch (Exception EX) { ClearDate(); }
    }
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 protected void DateValidate_ServerValidate(Object source, ServerValidateEventArgs e)
 {
     try
     {
         if (source.Equals(cvCalStartDateEmpty))
         {
             if (String.IsNullOrEmpty(calStartDate.getDate()))
             {
                 e.IsValid = false;
             }
             else
             {
                 e.IsValid = true;
             }
         }
         else if (source.Equals(cvCompareDates))
         {
             if (!String.IsNullOrEmpty(calStartDate.getDate()) && !String.IsNullOrEmpty(calEndDate.getDate()))
             {
                 int iStartDate = DateFun.ConvertDateTimeToInt(FormSession.DateType, calStartDate.getDate());
                 int iEndDate   = DateFun.ConvertDateTimeToInt(FormSession.DateType, calEndDate.getDate());
                 if (iStartDate > iEndDate)
                 {
                     e.IsValid = false;
                 }
                 else
                 {
                     e.IsValid = true;
                 }
             }
         }
     }
     catch { e.IsValid = false; }
 }
Example #5
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    protected void DateValidate_ServerValidate(Object source, ServerValidateEventArgs e)
    {
        try
        {
            if (source.Equals(cvcalStartDate))
            {
                if (string.IsNullOrEmpty(calStartdate.getDate()))
                {
                    General.ValidMsg(this, ref cvcalStartDate, false, "Start Date is required", "تاريخ البداية مطلوب");
                    e.IsValid = false;
                    return;
                }

                if (!string.IsNullOrEmpty(calStartdate.getDate()) && !String.IsNullOrEmpty(calEnddate.getDate()))
                {
                    int iStartDate = DateFun.ConvertDateTimeToInt("Gregorian", calStartdate.getDate());
                    int iEndDate   = DateFun.ConvertDateTimeToInt("Gregorian", calEnddate.getDate());
                    if (iStartDate > iEndDate)
                    {
                        General.ValidMsg(this, ref cvcalStartDate, true, "start date more than end date!", "تاريخ الإصدار أكبر من تاريخ الإنتهاء");
                        e.IsValid = false;
                        return;
                    }
                }
            }
        }
        catch { e.IsValid = false; }
    }
Example #6
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    static public void InsertError(string errorPage, string errorFunction)
    {
        string userID   = ((string)HttpContext.Current.Session["UserName"]);
        string userRole = Convert.ToString(HttpContext.Current.Session["Role"]);
        //string errorPage = "EmployeMaster.aspx";
        //string errorFunction = "btnSaveInsert";
        DateTime      dt         = DateTime.Now;
        StringBuilder errorQuery = new StringBuilder();

        errorQuery.Append("INSERT INTO [ErrorLog]([ErrorPage],[ErrorFunction],[ErrorDate] ,[LoginUserID],[LoginUserRole]) VALUES ('" + errorPage + "','" + errorFunction + "'");
        errorQuery.Append(",'" + DateFun.HijToGrn(DateFun.GrnToHij(dt)) + "','" + userID + "','" + userRole + "')");

        Int32 returnValue = ExecuteData(errorQuery.ToString());
    }
Example #7
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public string SelectDateFormat(string pDateType, string pDate)
    {
        //DateTime Date = Convert.ToDateTime(pDate);
        string strValue = "";

        if (pDateType == "Gregorian")
        {
            strValue = DateFun.strTodt(String.Format("{0:dd/MM/yyyy}", pDate)).ToShortDateString();
        }
        else if (pDateType == "Hijri")
        {
            strValue = DateFun.HijToGrn(pDate).ToShortDateString();
        }

        return(strValue);
    }
Example #8
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    protected void HireDateValidate_ServerValidate(Object source, ServerValidateEventArgs e)
    {
        try
        {
            if (source.Equals(cvCalHireDate))
            {
                if (!string.IsNullOrEmpty(CalHireDate.getDate()))
                {
                    int iStartDate = DateFun.ConvertDateTimeToInt(FormSession.DateType, CalHireDate.getDate());
                    int iEndDate   = DateFun.ConvertDateTimeToInt(FormSession.DateType, (DateFun.ToAnyFormat(FormSession.DateType, DateTime.Now)));
                    General.ValidMsg(this, ref cvCalHireDate, true, "Hire date greater than today's date", "تاريخ التعيين أكبر من تاريخ اليوم");

                    if (iStartDate > iEndDate)
                    {
                        e.IsValid = false;
                    }
                }
            }
        }
        catch { e.IsValid = false; }
    }
Example #9
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static string GrdDisplayDateTime(object pDate, object pType)
    {
        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
        string DType = "Gregorian";

        if (pDate != DBNull.Value && pType != DBNull.Value)
        {
            DateTime date = (DateTime)pDate;

            string Time = fd(Grn.GetHour(date).ToString()) + ":" + fd(Grn.GetMinute(date).ToString());

            if (pType.ToString() == "S")
            {
                DType = HttpContext.Current.Session["DateFormat"].ToString();
            }
            else if (pType.ToString() == "G")
            {
                DType = "Gregorian";
            }
            else if (pType.ToString() == "H")
            {
                DType = "Hijri";
            }

            if (DType == "Gregorian")
            {
                return(fd(Grn.GetDayOfMonth(date).ToString()) + "/" + fd(Grn.GetMonth(date).ToString()) + "/" + fd(Grn.GetYear(date).ToString()) + " " + Time);
            }
            if (DType == "Hijri")
            {
                return(DateFun.GrnToHij(Convert.ToDateTime(pDate)).ToString() + " " + Time);
            }
        }
        else
        {
            return(null);
        }

        return(null);
    }
Example #10
0
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public string GetCardInfo(string pCardID)
 {
     try
     {
         dt = DBFun.FetchData("SELECT ExpiryDate FROM CardMaster WHERE CardID = " + pCardID + "");
         if (!DBFun.IsNullOrEmpty(dt))
         {
             if (dt.Rows[0]["ExpiryDate"] != DBNull.Value)
             {
                 if (HttpContext.Current.Session["DateFormat"].ToString() == "Gregorian")
                 {
                     return((Convert.ToDateTime(dt.Rows[0]["ExpiryDate"])).ToString("dd/MM/yyyy"));
                 }
                 else if (HttpContext.Current.Session["DateFormat"].ToString() == "Hijri")
                 {
                     return(Convert.ToString(DateFun.GrnToHij(Convert.ToDateTime(dt.Rows[0]["ExpiryDate"]))));
                 }
             }
         }
         return(string.Empty);
     }
     catch (Exception e1) { return(string.Empty); }
 }
Example #11
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void setDBDate(object pDate, string pType)
    {
        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
        string DType = "Gregorian";

        if (pDate != DBNull.Value && !string.IsNullOrEmpty(pType))
        {
            DateTime date = (DateTime)pDate;
            if (pType == "S")
            {
                DType = Session["DateFormat"].ToString();
            }
            else if (pType == "G")
            {
                DType = "Gregorian";
            }
            else if (pType == "H")
            {
                DType = "Hijri";
            }

            this.txtType.Text = pType;
            if (DType == "Gregorian")
            {
                this.txtDate.Text = fd(Grn.GetDayOfMonth(date).ToString()) + "/" + fd(Grn.GetMonth(date).ToString()) + "/" + fd(Grn.GetYear(date).ToString());
            }
            if (DType == "Hijri")
            {
                this.txtDate.Text = DateFun.GrnToHij(Convert.ToDateTime(pDate)).ToString();
            }
        }
        else
        {
            ClearDate();
        }
    }
Example #12
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public bool Update(VisitorsPro pro)
    {
        SqlCommand sqlCommand = new SqlCommand("dbo.[VisitorsCard_Update]", MainConnection);

        sqlCommand.CommandType = CommandType.StoredProcedure;

        try
        {
            sqlCommand.Parameters.Add(new SqlParameter("@VisCardID", IntDB, 10, IN, false, 0, 0, "", DRV, pro.VisCardID));
            sqlCommand.Parameters.Add(new SqlParameter("@VisIdentityNo", VchDB, 100, IN, false, 0, 0, "", DRV, pro.VisIdentityNo));

            sqlCommand.Parameters.Add(new SqlParameter("@VisNameEn", VchDB, 500, IN, false, 0, 0, "", DRV, pro.VisNameEn));
            sqlCommand.Parameters.Add(new SqlParameter("@VisNameAr", VchDB, 500, IN, false, 0, 0, "", DRV, pro.VisNameAr));
            sqlCommand.Parameters.Add(new SqlParameter("@VisMobileNo", VchDB, 200, IN, false, 0, 0, "", DRV, pro.VisMobileNo));

            sqlCommand.Parameters.Add(new SqlParameter("@VisRegion1", BitDB, 1, IN, false, 0, 0, "", DRV, pro.VisRegion1));
            sqlCommand.Parameters.Add(new SqlParameter("@VisRegion2", BitDB, 1, IN, false, 0, 0, "", DRV, pro.VisRegion2));
            sqlCommand.Parameters.Add(new SqlParameter("@VisRegion3", BitDB, 1, IN, false, 0, 0, "", DRV, pro.VisRegion3));
            sqlCommand.Parameters.Add(new SqlParameter("@VisRegion4", BitDB, 1, IN, false, 0, 0, "", DRV, pro.VisRegion4));
            sqlCommand.Parameters.Add(new SqlParameter("@VisRegion5", BitDB, 1, IN, false, 0, 0, "", DRV, pro.VisRegion5));
            sqlCommand.Parameters.Add(new SqlParameter("@VisRegion6", BitDB, 1, IN, false, 0, 0, "", DRV, pro.VisRegion6));
            sqlCommand.Parameters.Add(new SqlParameter("@VisRegion7", BitDB, 1, IN, false, 0, 0, "", DRV, pro.VisRegion7));
            sqlCommand.Parameters.Add(new SqlParameter("@VisRegion8", BitDB, 1, IN, false, 0, 0, "", DRV, pro.VisRegion8));
            sqlCommand.Parameters.Add(new SqlParameter("@VisRegion9", BitDB, 1, IN, false, 0, 0, "", DRV, pro.VisRegion9));

            sqlCommand.Parameters.Add(new SqlParameter("@StartDate", DtDB, 14, IN, false, 0, 0, "", DRV, DateFun.SaveDB('S', pro.StartDate)));
            sqlCommand.Parameters.Add(new SqlParameter("@ExpiryDate", DtDB, 14, IN, false, 0, 0, "", DRV, DateFun.SaveDB('S', pro.ExpiryDate)));
            sqlCommand.Parameters.Add(new SqlParameter("@TmpID", IntDB, 10, IN, false, 0, 0, "", DRV, pro.TmpID));
            sqlCommand.Parameters.Add(new SqlParameter("@Description", VchDB, 1000, IN, false, 0, 0, "", DRV, pro.Description));

            sqlCommand.Parameters.Add(new SqlParameter("@CardStatus", IntDB, 10, IN, false, 0, 0, "", DRV, pro.CardStatus));
            //sqlCommand.Parameters.Add(new SqlParameter("@isPrinted", BitDB, 10, IN, false, 0, 0, "", DRV, pro.isPrinted));

            if (pro.VisImageLength > 0)
            {
                sqlCommand.Parameters.Add(new SqlParameter("@VisImage", SqlDbType.Image, 1000000, IN, false, 0, 0, "", DRV, pro.VisImage));
                sqlCommand.Parameters.Add(new SqlParameter("@VisImageContentType", VchDB, 100, IN, false, 0, 0, "", DRV, pro.VisImageContentType));
                sqlCommand.Parameters.Add(new SqlParameter("@VisImageLength", SqlDbType.BigInt, 100, IN, false, 0, 0, "", DRV, pro.VisImageLength.ToString()));
            }

            sqlCommand.Parameters.Add(new SqlParameter("@TransactionBy", VchDB, 50, IN, false, 0, 0, "", DRV, pro.TransactionBy));

            MainConnection.Open();

            sqlCommand.ExecuteNonQuery();
            return(true);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            MainConnection.Close();
            sqlCommand.Dispose();
        }
    }
Example #13
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public bool Insert(ErrorLogPro pro)
    {
        SqlCommand sqlCommand = new SqlCommand("dbo.[ErrorLog_Insert]", MainConnection);

        sqlCommand.CommandType = CommandType.StoredProcedure;

        try
        {
            sqlCommand.Parameters.Add(new SqlParameter("@ErrorPage", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.ErrorPage));
            sqlCommand.Parameters.Add(new SqlParameter("@ErrorFunction", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.ErrorFunction));
            sqlCommand.Parameters.Add(new SqlParameter("@ErrorMessage", SqlDbType.VarChar, 5000, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.ErrorMessage));
            sqlCommand.Parameters.Add(new SqlParameter("@ErrorDate", SqlDbType.VarChar, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, DateFun.SaveDB('S', pro.ErrorDate)));
            sqlCommand.Parameters.Add(new SqlParameter("@LoginUserID", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.LoginUserID));
            sqlCommand.Parameters.Add(new SqlParameter("@LoginUserRole", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.LoginUserRole));

            MainConnection.Open();

            sqlCommand.ExecuteNonQuery();
            return(true);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            MainConnection.Close();
            sqlCommand.Dispose();
        }
    }
Example #14
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public bool Insert(EmployeePro pro)
    {
        SqlCommand sqlCommand = new SqlCommand("dbo.[Employee_Insert]", MainConnection);

        sqlCommand.CommandType = CommandType.StoredProcedure;

        try
        {
            sqlCommand.Parameters.Add(new SqlParameter("@EmpID", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpID));
            sqlCommand.Parameters.Add(new SqlParameter("@EmpType", SqlDbType.VarChar, 3, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpType));
            sqlCommand.Parameters.Add(new SqlParameter("@EmpNameAr", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpNameAr));
            sqlCommand.Parameters.Add(new SqlParameter("@EmpNameEn", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpNameEn));
            sqlCommand.Parameters.Add(new SqlParameter("@NatID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.NatID));
            sqlCommand.Parameters.Add(new SqlParameter("@EmpBirthDate", SqlDbType.VarChar, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, DateFun.SaveDB('S', pro.EmpBirthDate)));
            sqlCommand.Parameters.Add(new SqlParameter("@EmpJobTitleAr", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpJobTitleAr));
            sqlCommand.Parameters.Add(new SqlParameter("@EmpJobTitleEn", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpJobTitleEn));
            sqlCommand.Parameters.Add(new SqlParameter("@EmpNationalID", SqlDbType.VarChar, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpNationalID));
            sqlCommand.Parameters.Add(new SqlParameter("@EmpBloodGroup", SqlDbType.VarChar, 3, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpBloodGroup));
            sqlCommand.Parameters.Add(new SqlParameter("@CompID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.CompID));
            sqlCommand.Parameters.Add(new SqlParameter("@SecID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.SecID));

            if (!String.IsNullOrEmpty(pro.EmpHireDate))
            {
                sqlCommand.Parameters.Add(new SqlParameter("@EmpHireDate", SqlDbType.VarChar, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, DateFun.SaveDB('S', pro.EmpHireDate)));
            }
            sqlCommand.Parameters.Add(new SqlParameter("@EmpGender", SqlDbType.Char, 1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpGender));
            sqlCommand.Parameters.Add(new SqlParameter("@EmpMobileNo", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpMobileNo));
            sqlCommand.Parameters.Add(new SqlParameter("@EmpEmailID", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpEmailID));

            if (pro.EmpImageLength > 0)
            {
                sqlCommand.Parameters.Add(new SqlParameter("@Image", SqlDbType.Image, 1000000, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpImage));
                sqlCommand.Parameters.Add(new SqlParameter("@ImageContentType", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpImageContentType));
                sqlCommand.Parameters.Add(new SqlParameter("@ImageLength", SqlDbType.BigInt, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpImageLength.ToString()));
            }
            sqlCommand.Parameters.Add(new SqlParameter("@TransactionBy", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.TransactionBy));

            MainConnection.Open();

            sqlCommand.ExecuteNonQuery();
            return(true);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            MainConnection.Close();
            sqlCommand.Dispose();
        }
    }
Example #15
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public bool Update(AppUsersPro pro)
    {
        SqlCommand sqlCommand = new SqlCommand("dbo.[AppUsers_Update]", MainConnection);

        sqlCommand.CommandType = CommandType.StoredProcedure;

        try
        {
            sqlCommand.Parameters.Add(new SqlParameter("@UsrLoginID", VchDB, 50, IN, false, 0, 0, "", DRV, pro.UsrLoginID));
            sqlCommand.Parameters.Add(new SqlParameter("@UsrPassword", VchDB, 100, IN, false, 0, 0, "", DRV, pro.UsrPassword));
            sqlCommand.Parameters.Add(new SqlParameter("@UsrFullName", VchDB, 200, IN, false, 0, 0, "", DRV, pro.UsrFullName));

            if (!string.IsNullOrEmpty(pro.UsrStartDate))
            {
                sqlCommand.Parameters.Add(new SqlParameter("@UsrStartDate", DtDB, 14, IN, false, 0, 0, "", DRV, DateFun.SaveDB(pro.UsrStartDateType, pro.UsrStartDate)));
                sqlCommand.Parameters.Add(new SqlParameter("@UsrStartDateType", ChrDB, 1, IN, false, 0, 0, "", DRV, pro.UsrStartDateType));
            }

            if (!string.IsNullOrEmpty(pro.UsrExpiryDate))
            {
                sqlCommand.Parameters.Add(new SqlParameter("@UsrExpiryDate", DtDB, 14, IN, false, 0, 0, "", DRV, DateFun.SaveDB(pro.UsrExpiryDateType, pro.UsrExpiryDate)));
                sqlCommand.Parameters.Add(new SqlParameter("@UsrExpiryDateType", ChrDB, 1, IN, false, 0, 0, "", DRV, pro.UsrExpiryDateType));
            }

            sqlCommand.Parameters.Add(new SqlParameter("@UsrStatus", BitDB, 1, IN, false, 0, 0, "", DRV, pro.UsrStatus));
            sqlCommand.Parameters.Add(new SqlParameter("@UsrPermission", VchDB, 8000, IN, false, 0, 0, "", DRV, pro.UsrPermission));
            sqlCommand.Parameters.Add(new SqlParameter("@UsrLanguage", VchDB, 50, IN, false, 0, 0, "", DRV, pro.UsrLanguage));
            sqlCommand.Parameters.Add(new SqlParameter("@UsrEmailID", VchDB, 200, IN, false, 0, 0, "", DRV, pro.UsrEmailID));
            sqlCommand.Parameters.Add(new SqlParameter("@UsrEmpID", VchDB, 100, IN, false, 0, 0, "", DRV, pro.UsrEmpID));
            sqlCommand.Parameters.Add(new SqlParameter("@UsrDescription", VchDB, 8000, IN, false, 0, 0, "", DRV, pro.UsrDescription));

            sqlCommand.Parameters.Add(new SqlParameter("@TransactionBy", VchDB, 50, IN, false, 0, 0, "", DRV, pro.TransactionBy));


            MainConnection.Open();

            sqlCommand.ExecuteNonQuery();
            return(true);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            MainConnection.Close();
            sqlCommand.Dispose();
        }
    }
Example #16
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public int Insert(CardsPro pro)
    {
        SqlCommand sqlCommand = new SqlCommand();

        sqlCommand.CommandText = "dbo.[Cards_Insert]";
        sqlCommand.CommandType = CommandType.StoredProcedure;
        sqlCommand.Connection  = MainConnection;

        try
        {
            sqlCommand.Parameters.Add(new SqlParameter("@CardID", SqlDbType.Int, 10, ParameterDirection.Output, false, 0, 0, "", DataRowVersion.Proposed, pro.CardID));

            sqlCommand.Parameters.Add(new SqlParameter("@EmpID", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpID));
            sqlCommand.Parameters.Add(new SqlParameter("@IsID", SqlDbType.Int, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.IsID));
            sqlCommand.Parameters.Add(new SqlParameter("@CardCount", SqlDbType.Int, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.CardCount));

            sqlCommand.Parameters.Add(new SqlParameter("@StartDate", SqlDbType.DateTime, 14, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, DateFun.SaveDB('S', pro.StartDate)));
            sqlCommand.Parameters.Add(new SqlParameter("@ExpiryDate", SqlDbType.DateTime, 14, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, DateFun.SaveDB('S', pro.ExpiryDate)));
            sqlCommand.Parameters.Add(new SqlParameter("@TmpID", SqlDbType.Int, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.TmpID));
            sqlCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.VarChar, 250, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.Description));

            sqlCommand.Parameters.Add(new SqlParameter("@CardStatus", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.CardStatus));
            sqlCommand.Parameters.Add(new SqlParameter("@InActiveStatus", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.InActiveStatus));
            sqlCommand.Parameters.Add(new SqlParameter("@IsApproved", SqlDbType.Int, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.IsApproved));
            sqlCommand.Parameters.Add(new SqlParameter("@isPrinted", SqlDbType.Bit, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.isPrinted));

            sqlCommand.Parameters.Add(new SqlParameter("@CreatedBy", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.TransactionBy));
            sqlCommand.Parameters.Add(new SqlParameter("@CreatedDate", SqlDbType.DateTime, 14, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.TransactionDate));

            MainConnection.Open();

            int rowsAffected = sqlCommand.ExecuteNonQuery();
            rowsAffected = Convert.ToInt32(sqlCommand.Parameters["@CardID"].Value);
            return(rowsAffected);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            MainConnection.Close();
            sqlCommand.Dispose();
        }
    }
Example #17
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public bool Update(CardsPro pro)
    {
        SqlCommand sqlCommand = new SqlCommand();

        sqlCommand.CommandText = "dbo.[Cards_Update]";
        sqlCommand.CommandType = CommandType.StoredProcedure;
        sqlCommand.Connection  = MainConnection;

        try
        {
            sqlCommand.Parameters.Add(new SqlParameter("@CardID", SqlDbType.Int, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.CardID));

            sqlCommand.Parameters.Add(new SqlParameter("@EmpID", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.EmpID));
            sqlCommand.Parameters.Add(new SqlParameter("@IsID", SqlDbType.Int, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.IsID));
            sqlCommand.Parameters.Add(new SqlParameter("@CardCount", SqlDbType.Int, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.CardCount));

            sqlCommand.Parameters.Add(new SqlParameter("@StartDate", SqlDbType.DateTime, 14, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, DateFun.SaveDB('S', pro.StartDate)));
            sqlCommand.Parameters.Add(new SqlParameter("@ExpiryDate", SqlDbType.DateTime, 14, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, DateFun.SaveDB('S', pro.ExpiryDate)));
            sqlCommand.Parameters.Add(new SqlParameter("@TmpID", SqlDbType.Int, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.TmpID));
            sqlCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.VarChar, 250, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.Description));
            sqlCommand.Parameters.Add(new SqlParameter("@CardStatus", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.CardStatus));

            sqlCommand.Parameters.Add(new SqlParameter("@TransactionBy", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.TransactionBy));

            MainConnection.Open();

            sqlCommand.ExecuteNonQuery();
            return(true);
        }
        catch (Exception ex)
        {
            throw new Exception("Cards::Update::Error occured.", ex);
        }
        finally
        {
            MainConnection.Close();
            sqlCommand.Dispose();
        }
    }
Example #18
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public bool Update(StickersPro Pro)
    {
        SqlCommand sqlCmd = new SqlCommand("dbo.[StickerMaster_Update]", MainConnection);

        sqlCmd.CommandType = CommandType.StoredProcedure;

        try
        {
            sqlCmd.Parameters.Add(new SqlParameter("@StickerID", SqlDbType.Int, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.StickerID));
            sqlCmd.Parameters.Add(new SqlParameter("@RegVehicle", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.RegVehicle));
            sqlCmd.Parameters.Add(new SqlParameter("@EmpID", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.EmpID));

            if (!string.IsNullOrEmpty(Pro.StartDate))
            {
                sqlCmd.Parameters.Add(new SqlParameter("@StartDate", SqlDbType.DateTime, 14, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, DateFun.SaveDB('G', Pro.StartDate)));
            }
            if (!string.IsNullOrEmpty(Pro.ExpiryDate))
            {
                sqlCmd.Parameters.Add(new SqlParameter("@ExpiryDate", SqlDbType.DateTime, 14, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, DateFun.SaveDB('G', Pro.ExpiryDate)));
            }

            sqlCmd.Parameters.Add(new SqlParameter("@Owner", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.Owner));
            sqlCmd.Parameters.Add(new SqlParameter("@CarType", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.CarType));
            sqlCmd.Parameters.Add(new SqlParameter("@Model", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.Model));
            sqlCmd.Parameters.Add(new SqlParameter("@Color", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.Color));

            sqlCmd.Parameters.Add(new SqlParameter("@TemplateID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.TemplateID));
            sqlCmd.Parameters.Add(new SqlParameter("@CompID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.CompID));

            sqlCmd.Parameters.Add(new SqlParameter("@Printed", SqlDbType.Bit, 1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, true));
            sqlCmd.Parameters.Add(new SqlParameter("@Status", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.Status));

            sqlCmd.Parameters.Add(new SqlParameter("@TransactionBy", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, Pro.TransactionBy));

            MainConnection.Open();

            sqlCmd.ExecuteNonQuery();
            return(true);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            MainConnection.Close();
            sqlCmd.Dispose();
        }
    }
Example #19
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    protected void ShowReport()
    {
        StiWebViewerFx1.Report = null;

        if (lstReport.SelectedIndex < 0)
        {
            return;
        }
        string RepID = lstReport.SelectedValue;

        string    RepTemp = "";
        DataTable RepDT   = DBFun.FetchData(" SELECT * FROM Report WHERE RepID = '" + RepID + "'");

        if (!DBFun.IsNullOrEmpty(RepDT))
        {
            RepTemp = RepDT.Rows[0]["RepTemp" + FormSession.Language].ToString();
            string RepOrientation = RepDT.Rows[0]["RepOrientation"].ToString();
            ViewState["RepOrientation"] = RepDT.Rows[0]["RepOrientation"].ToString();

            StiReport StiRep = new StiReport();
            StiRep.LoadFromString(RepTemp);
            StiRep.Dictionary.Databases.Clear();
            StiRep.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", General.ConnString));
            StiRep.GetSubReport += new StiGetSubReportEventHandler(rep_GetSubReport);
            StiRep.Dictionary.Synchronize();
            StiRep.Compile();

            /////// Fill Parameters to Report
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            if (pnlDateFromTo.Visible)
            {
                StiRep["ParamDateFrom"] = DateFun.GetGregDateTime(calStartDate.getDate(), 'S', "F");
                StiRep["ParamDateTo"]   = DateFun.GetGregDateTime(calEndDate.getDate(), 'S', "T");
            }

            if (pnlEmployee.Visible)
            {
                StiRep["EmpID"] = ViewState["EmpID"].ToString();
            }
            if (pnlCreatedBy.Visible)
            {
                StiRep["CreatedBy"] = ddlCreatedBy.SelectedValue;
            }
            if (pnlPrintedBy.Visible)
            {
                StiRep["PrintedBy"] = ddlPrintedBy.SelectedValue;
            }
            if (pnlIssue.Visible)
            {
                StiRep["IssueID"] = Convert.ToInt32(ddlIssue.SelectedValue);
            }
            if (pnlEmpType.Visible)
            {
                StiRep["EmpType"] = ddlEmpType.SelectedValue;
                StiRep["CompID"]  = ddlCompID.SelectedValue;
                StiRep["HasCard"] = ddlHasCard.SelectedValue;
            }

            StiRep["LoginID"] = FormSession.LoginUsr;

            StiRep.Render();
            StiWebViewerFx1.Report = StiRep;
        }
    }