Beispiel #1
0
        private bool IsValidDateTime(DateTime dateTime)
        {
            var isValid = false;

            if (dateTime == null) return true;

            var testDate = DateTime.MinValue;
            var minValue = DateTime.Parse(System.Data.SqlTypes.SqlDateTime.MinValue.ToString());
            var maxValue = DateTime.Parse(System.Data.SqlTypes.SqlDateTime.MaxValue.ToString());

            System.Data.SqlTypes.SqlDateTime sdt;

            if (minValue > dateTime || maxValue < dateTime)
                return false;

            if (DateTime.TryParse(dateTime.ToString(), out testDate))
            {
                try
                {
                    // take advantage of the native conversion
                    sdt = new System.Data.SqlTypes.SqlDateTime(testDate);
                    isValid = true;
                }
                catch (System.Data.SqlTypes.SqlTypeException ex)
                {

                    // no need to do anything, this is the expected out of range error
                }
            }

            return true;
        }
 /// <summary>
 /// This method allows to clear all the properties previously loaded by a call to the Refresh method.
 /// </summary>
 public void Reset()
 {
     this.col_Ord_GuidID        = System.Data.SqlTypes.SqlGuid.Null;
     this.col_Ord_DatOrderedOn  = System.Data.SqlTypes.SqlDateTime.Null;
     this.col_Ord_LngCustomerID = System.Data.SqlTypes.SqlInt32.Null;
     this.col_Ord_CurTotal      = System.Data.SqlTypes.SqlMoney.Null;
 }
Beispiel #3
0
        private bool CheckValues()
        {
            bool status = true;

            try {
                System.Data.SqlTypes.SqlDateTime value = new System.Data.SqlTypes.SqlDateTime(System.Convert.ToDateTime(txt_Ord_DatOrderedOn.Text));
            }

            catch {
                labError_Ord_DatOrderedOn.Text    = "INVALID";
                labError_Ord_DatOrderedOn.Visible = true;
                status = false;
            }

            try {
                System.Data.SqlTypes.SqlMoney value = new System.Data.SqlTypes.SqlMoney(System.Convert.ToDecimal(txt_Ord_CurTotal.Text));
            }

            catch {
                labError_Ord_CurTotal.Text    = "INVALID";
                labError_Ord_CurTotal.Visible = true;
                status = false;
            }

            return(status);
        }
Beispiel #4
0
        /// <summary>
        /// Validates date input in textbox
        /// </summary>
        /// <param name="dateStr">String to validate</param>
        /// <returns>true if input string is valid date</returns>
        public bool ValidateDate(string dateStr)
        {
            DateTime date = default;

            // Validate that date format is valid
            if (!DateTime.TryParseExact(dateStr, "yyyy-mm-dd", CultureInfo.GetCultureInfo("en-US").DateTimeFormat, DateTimeStyles.None, out date))
            {
                // parse failed.
                lblDateError.Visible = true;
                return(false);
            }

            // validate that date can be parsed to SQL DateTime type
            try
            {
                System.Data.SqlTypes.SqlDateTime dtSql = System.Data.SqlTypes.SqlDateTime.Parse(date.ToString("yyyy-mm-dd"));
            }
            catch (System.FormatException e)
            {
                lblDateError.Visible = true;
                return(false);
            }
            catch (System.Data.SqlTypes.SqlTypeException e)
            {
                lblDateError.Visible = true;
                return(false);
            }

            // remove error message
            lblDateError.Visible = false;

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// This method allows you to reset the parameter object. Please note that this
        /// method resets all the parameters members except the connection information and
        /// the command time-out which are left in their current state.
        /// </summary>
        public void Reset()
        {
            this.internal_Param_RETURN_VALUE = System.Data.SqlTypes.SqlInt32.Null;

            this.internal_Param_JobId = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_JobId_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Description = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Description_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Price = System.Data.SqlTypes.SqlMoney.Null;
            this.internal_Param_Price_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_StartDate = System.Data.SqlTypes.SqlDateTime.Null;
            this.internal_Param_StartDate_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_EndDate = System.Data.SqlTypes.SqlDateTime.Null;
            this.internal_Param_EndDate_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_CustomerId = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_CustomerId_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
 /// <summary>
 /// This method allows to clear all the properties previously loaded by a call to the Refresh method.
 /// </summary>
 public void Reset()
 {
     this.col_JobId       = System.Data.SqlTypes.SqlInt32.Null;
     this.col_Description = System.Data.SqlTypes.SqlString.Null;
     this.col_Price       = System.Data.SqlTypes.SqlMoney.Null;
     this.col_StartDate   = System.Data.SqlTypes.SqlDateTime.Null;
     this.col_EndDate     = System.Data.SqlTypes.SqlDateTime.Null;
     this.col_CustomerId  = System.Data.SqlTypes.SqlInt32.Null;
 }
Beispiel #7
0
            public TestTableRow AddTestTableRow(System.Data.SqlTypes.SqlDateTime DateTimeValue)
            {
                TestTableRow rowTestTableRow = ((TestTableRow)(this.NewRow()));

                object[] columnValuesArray = new object[] {
                    DateTimeValue
                };
                rowTestTableRow.ItemArray = columnValuesArray;
                this.Rows.Add(rowTestTableRow);
                return(rowTestTableRow);
            }
Beispiel #8
0
 /// <summary>
 /// Verifies whether a value is 
 /// kosher for SQL Server datetime. This uses the native library
 /// for checking range values
 /// </summary>
 /// <param name="someval">A date string that may parse</param>
 private static void ValidateSqlDateTimeNative(string someval)
 {
     DateTime testDate = DateTime.MinValue;
     System.Data.SqlTypes.SqlDateTime sdt;
     if (DateTime.TryParse(someval, out testDate))
     {
         try
         {
             sdt = new System.Data.SqlTypes.SqlDateTime(testDate);
         }
         catch (System.Data.SqlTypes.SqlTypeException exception)
         {
             throw new InvalidFieldValueException("Published day is in wrong format.", "PublishedDate", exception);
         }
     }
 }
Beispiel #9
0
		public void Save() 
		{
			try 
			{
				if (System.Web.HttpContext.Current.Request.Form[this.ClientID] != "") 
				{
					DateTime tempDate = DateTime.Parse(System.Web.HttpContext.Current.Request.Form[this.ClientID]);
					this.Text = tempDate.ToLongDateString() + " " + tempDate.ToLongTimeString();
					System.Data.SqlTypes.SqlDateTime sqlDate = new System.Data.SqlTypes.SqlDateTime(tempDate);
					_data.Value = sqlDate;
				} else
					_data.Value = null;
			} 
			catch {
				_data.Value = null;
			}
		}
Beispiel #10
0
 public static bool IsValidSqlDateTime(DateTime t)
 {
     // Cant the SQL db store this date as datetime?
     try
     {
         if (t == DateTime.MinValue) // same as default(DateTime)
         {
             return(false);
         }
         System.Data.SqlTypes.SqlDateTime dsql = t;
         return(true);    // didn't throw = ok.
     }
     catch
     {
         return(false);
     }
 }
        /// <summary>Test for a valid SQL Server datetime string.</summary>
        /// <param name="value">The date string to test.</param>
        /// <returns>True if the parameter is a SQL Sever datetime; otherwise false.</returns>
        static bool IsValidSqlDateTimeNative(string value)
        {
            bool     valid    = false;
            DateTime testDate = DateTime.MinValue;

            System.Data.SqlTypes.SqlDateTime sdt;
            if (DateTime.TryParse(value, out testDate))
            {
                try
                {
                    sdt   = new System.Data.SqlTypes.SqlDateTime(testDate);
                    valid = true;
                }
                catch (System.Data.SqlTypes.SqlTypeException) { }
            }

            return(valid);
        }
Beispiel #12
0
        public override void SetAuditFields(EntityState state)
        {
            string   username  = FACTS.Framework.Service.Context.UserName ?? "UNKNOWN";
            DateTime timestamp = DateTime.Now;

            if (state == EntityState.Added)
            {
                CreateUserId   = username;
                CreateDateTime = new System.Data.SqlTypes.SqlDateTime(timestamp).Value;
                UpdateUserId   = username;
                UpdateDateTime = new System.Data.SqlTypes.SqlDateTime(timestamp).Value;
            }
            else if (state == EntityState.Modified)
            {
                UpdateUserId   = username;
                UpdateDateTime = new System.Data.SqlTypes.SqlDateTime(timestamp).Value;
            }
        }
Beispiel #13
0
        /// <summary>
        /// This method allows you to reset the parameter object. Please note that this
        /// method resets all the parameters members except the connection information and
        /// the command time-out which are left in their current state.
        /// </summary>
        public void Reset()
        {
            this.internal_Param_RETURN_VALUE = System.Data.SqlTypes.SqlInt32.Null;

            this.internal_Param_Ord_GuidID = System.Data.SqlTypes.SqlGuid.Null;
            this.internal_Param_Ord_GuidID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Ord_DatOrderedOn = System.Data.SqlTypes.SqlDateTime.Null;
            this.internal_Param_Ord_DatOrderedOn_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Ord_LngCustomerID = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_Ord_LngCustomerID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Ord_CurTotal = System.Data.SqlTypes.SqlMoney.Null;
            this.internal_Param_Ord_CurTotal_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
Beispiel #14
0
        // https://stackoverflow.com/questions/7054782/validate-datetime-before-inserting-it-into-sql-server-database
        /// <summary>
        /// An method to verify whether a value is
        /// kosher for SQL Server datetime.
        /// </summary>
        /// <param name="dateToCheck">A date string that may parse</param>
        /// <returns>True if the parameter is valid for SQL Sever datetime</returns>
        public bool IsValidSqlDateTime(DateTime dateToCheck)
        {
            bool     valid    = false;
            DateTime testDate = DateTime.MinValue;

            System.Data.SqlTypes.SqlDateTime sqlDateTime;

            try
            {
                // take advantage of the native conversion
                sqlDateTime = new System.Data.SqlTypes.SqlDateTime(dateToCheck);
                valid       = true;
            }
            catch (System.Data.SqlTypes.SqlTypeException ex)
            {
                // no need to do anything, this is the expected out of range error
            }

            return(valid);
        }
Beispiel #15
0
 public void Save()
 {
     try
     {
         if (System.Web.HttpContext.Current.Request.Form[this.ClientID] != "")
         {
             DateTime tempDate = DateTime.Parse(System.Web.HttpContext.Current.Request.Form[this.ClientID]);
             this.Text = tempDate.ToLongDateString() + " " + tempDate.ToLongTimeString();
             System.Data.SqlTypes.SqlDateTime sqlDate = new System.Data.SqlTypes.SqlDateTime(tempDate);
             _data.Value = sqlDate;
         }
         else
         {
             _data.Value = null;
         }
     }
     catch {
         _data.Value = null;
     }
 }
        private bool IsValidSqlDateTimeNative(object someval)
        {
            bool valid = false;
            string dt = Convert.ToString(someval);

            DateTime testDate = DateTime.MinValue;
            System.Data.SqlTypes.SqlDateTime sdt;
            if (DateTime.TryParse(dt, out testDate))
            {
                try
                {
                    sdt = new System.Data.SqlTypes.SqlDateTime(testDate);
                    valid = true;
                }
                catch
                {
                }
            }

            return valid;
        }
    static bool IsValidSqlDateTimeNative(string someval)
    {
        bool     valid    = false;
        DateTime testDate = DateTime.MinValue;

        System.Data.SqlTypes.SqlDateTime sdt;
        if (DateTime.TryParse(someval, out testDate))
        {
            try
            {
                // take advantage of the native conversion
                sdt   = new System.Data.SqlTypes.SqlDateTime(testDate);
                valid = true;
            }
            catch (System.Data.SqlTypes.SqlTypeException ex)
            {
                // no need to do anything, this is the expected out of range error
            }
        }
        return(valid);
    }
        public override void SetAuditFields(EntityState state)
        {
            string   username  = FACTS.Framework.Service.Context.UserName ?? "UNKNOWN";
            DateTime timestamp = FACTS.Framework.Utility.DateTimeUtil.Now;

            if (state == EntityState.Added)
            {
                CreateUserId   = username;
                CreateDateTime = new System.Data.SqlTypes.SqlDateTime(timestamp).Value;
                UpdateUserId   = username;
                UpdateDateTime = new System.Data.SqlTypes.SqlDateTime(timestamp).Value;
                UpdateNumber   = 0;
                UpdateProcess  = FACTS.Framework.Utility.StringUtil.CapLength(FACTS.Framework.Service.Context.Process.ToString(), 100);
            }
            else if (state == EntityState.Modified)
            {
                UpdateUserId   = username;
                UpdateDateTime = new System.Data.SqlTypes.SqlDateTime(timestamp).Value;
                UpdateNumber   = (UpdateNumber ?? 0) + 1;
                UpdateProcess  = FACTS.Framework.Utility.StringUtil.CapLength(FACTS.Framework.Service.Context.Process.ToString(), 100);
            }
        }
Beispiel #19
0
        public static void WriteData(TdsParameter p, TdsRequestStream stream, Encoding encoder)
        {
            switch (p.TdsType)
            {
            case TdsType.TDS_VARCHAR:
                if (p.Value == null)
                {
                    stream.Write((byte)0);
                }
                else
                {
                    var s      = (string)p.Value;
                    var bytes  = encoder.GetBytes(s);
                    int strLen = Math.Max(VAR_MAX, bytes.Length);
                    stream.Write((byte)strLen);
                    stream.Write(bytes, 0, strLen);
                }
                break;

            case TdsType.TDS_VARBINARY:
                if (p.Value == null)
                {
                    stream.Write((byte)0);
                }
                else
                {
                    var bytes    = (byte[])p.Value;
                    int bytesLen = Math.Max(VAR_MAX, bytes.Length);
                    stream.Write((byte)bytesLen);
                    stream.Write(bytes, 0, bytesLen);
                }
                break;

            case TdsType.TDS_INTN:
                if (p.Value == null)
                {
                    stream.Write((byte)0);
                }
                else if (p.Value.GetType() == typeof(long))
                {
                    stream.Write((byte)8);
                    stream.WriteLong((long)p.Value);
                }
                else     // convert all smaller ints to int32
                {
                    stream.Write((byte)4);
                    stream.WriteInt((int)p.Value);
                }
                break;

            case TdsType.TDS_FLTN:
                if (p.Value == null)
                {
                    stream.Write((byte)0);
                }
                else if (p.Value.GetType() == typeof(float))
                {
                    stream.Write((byte)4);
                    stream.WriteInt(BitConverter.SingleToInt32Bits((float)p.Value));
                }
                else     // double
                {
                    stream.Write((byte)8);
                    stream.WriteLong(BitConverter.DoubleToInt64Bits((double)p.Value));
                }
                break;

            case TdsType.TDS_DATETIMEN:
                if (p.Value == null)
                {
                    stream.Write((byte)0);
                }
                else
                {
                    stream.Write((byte)8);
                    var dt = new System.Data.SqlTypes.SqlDateTime((DateTime)p.Value);
                    stream.WriteInt(dt.DayTicks);
                    stream.WriteInt(dt.TimeTicks);
                }
                break;

            case TdsType.TDS_DECN:
                if (p.Value == null)
                {
                    stream.Write((byte)0);
                }
                else
                {
                    var sqlDec = new System.Data.SqlTypes.SqlDecimal((decimal)p.Value);
                    stream.Write((byte)17);
                    stream.Write(sqlDec.IsPositive ? (byte)0 : (byte)1);
                    stream.Write(sqlDec.BinData.Reverse().ToArray());
                }
                break;

            case TdsType.TDS_MONEYN:
                //if (value == null)
                //{
                stream.Write((byte)0);
                //}
                //else
                //{
                //}
                break;

            case TdsType.TDS_BIT:
                stream.Write((bool)p.Value ? (byte)1 : (byte)0);
                break;

            default:
                throw new NotImplementedException($"Unsupported type {p.TdsType}");
            }
        }
        private void SaveAdmissionDetails(string strAction)
        {
            try
            {
                EWA_Admission objEWA = new EWA_Admission();
                BL_Admission  objBAL = new BL_Admission();

                // Get College ID And Name From Session

                // Panel 1

                objEWA.TransationAction = strAction.ToString();
                objEWA.AdmissionID      = lbl_ApplicationId.Text.ToString();

                //System.Data.SqlTypes.SqlDateTime AdmissionDate = System.Data.SqlTypes.SqlDateTime.Parse(lblAdmissionDate.Text);
                DateTime datetime1 = Convert.ToDateTime(lblAdmissionDate.Text);

                objEWA.AdmissionDate = datetime1.ToString();
                objEWA.OrgID         = Convert.ToInt32(Session["OrgId"]);

                objEWA.AdmissionType = ddl_AdmissionType.SelectedValue.ToString().Trim();
                objEWA.Course        = ddl_Course.SelectedValue.Trim().Trim();
                objEWA.Branch_ID     = Convert.ToInt32(ddl_Branch.SelectedValue);
                objEWA.Class1        = ddl_Class.SelectedValue.Trim().Trim();

                objEWA.PreviousRollNo = txt_PreviousRollNo.Text.Trim();
                objEWA.FeesCategory   = ddl_FeesCategory.SelectedItem.ToString().Trim();
                objEWA.CasteCategory  = ddl_CasteCategory.SelectedValue.Trim();

                // Panel 2

                objEWA.FirstName  = txt_FirstName.Text.Trim();
                objEWA.MiddleName = txt_MiddleName.Text.Trim();
                objEWA.LastName   = txt_LastName.Text.Trim();
                objEWA.Gender1    = rbt_Gender.SelectedItem.ToString();



                System.Data.SqlTypes.SqlDateTime birthdate = System.Data.SqlTypes.SqlDateTime.Parse(txt_BirthDate.Text);

                // DateTime birthdate = DateTime.ParseExact(txt_BirthDate.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture);


                DateTime datetime = Convert.ToDateTime(txt_BirthDate.Text);
                objEWA.BirthDate = datetime.ToString();



                objEWA.BirthPlace   = txt_BirthPlace.Text.Trim();
                objEWA.AddressLine1 = txt_Address1.Text.Trim();
                objEWA.AddressLine2 = txt_Address2.Text.Trim();
                objEWA.Country1     = ddl_Country.SelectedValue.ToString();
                objEWA.State1       = ddl_State.SelectedValue.ToString();
                objEWA.District1    = ddl_District.SelectedValue.ToString();
                objEWA.Taluka1      = TxtTaluka.Text.Trim();
                objEWA.City1        = TxtCity.Text.Trim();
                if (txt_Pincode.Text != string.Empty)
                {
                    objEWA.PinCode1 = Convert.ToInt32(txt_Pincode.Text);
                }

                objEWA.MarriedStatus = rbt_MarriedStatus.SelectedValue.ToString();
                objEWA.MobileNo      = txt_PersonalMobile.Text.Trim();
                objEWA.E_Mail        = txt_Email.Text.Trim();
                objEWA.Nationality1  = DDL_Nationality.SelectedValue.ToString();

                objEWA.BloodGroup    = ddl_BloodGroup.SelectedValue.ToString();
                objEWA.Handicaped    = ddl_Handicap.SelectedValue.ToString();
                objEWA.Conveyanceuse = ddl_ConveyanceUse.SelectedValue.ToString();
                objEWA.Religion1     = ddl_Religion.SelectedValue.ToString();
                objEWA.Caste1        = ddl_Caste.SelectedItem.ToString();
                objEWA.Subcaste      = txtSubcast.Text.Trim();


                objEWA.SportId = DDL_Sports.SelectedValue.ToString();
                objEWA.AdharNo = DDL_SportLevel.SelectedItem.ToString();

                // Panel 3
                objEWA.GuardianName     = txt_GuardianName.Text.ToString();
                objEWA.Relation1        = ddl_Relation.SelectedItem.ToString();
                objEWA.GuardianAddress1 = txt_GuardianAddress1.Text.ToString().Trim();
                objEWA.GuardianAddress2 = txt_GuardianAddress2.Text.ToString().Trim();
                objEWA.GuardianCountry  = ddl_GuardianCountry.SelectedItem.ToString().Trim();
                objEWA.GuardianState    = ddl_GuardianState.SelectedItem.ToString();
                objEWA.GuardianDistrict = ddl_GuardianDistrict.SelectedItem.ToString();
                objEWA.GuardianTaluka   = txtGuardianTaluka.Text.ToString().Trim();
                objEWA.GuardianCity     = txtGuardianCity.Text;
                if (txt_GuardianPincode.Text != string.Empty)
                {
                    objEWA.GuardianPinCode = Convert.ToInt32(txt_GuardianPincode.Text);
                }

                objEWA.GuardianMobile = txt_GuardianMobile.Text.Trim();
                objEWA.GuardianEmail  = txt_GuardianEmail.Text.Trim();

                // Panel Parent information

                objEWA.ParentName     = txt_ParentName.Text.Trim();
                objEWA.MotherName     = txt_MotherName.Text.Trim();
                objEWA.ParentAddress1 = txt_ParentAddress1.Text.Trim();
                objEWA.ParentAddress2 = txt_ParentAddress2.Text.Trim();
                objEWA.ParentCountry  = ddl_ParentCountry.SelectedItem.ToString();
                objEWA.ParentState    = ddl_ParentState.SelectedItem.ToString();
                objEWA.ParentTaluka   = txt_ParentCity.Text.ToString().Trim();
                if (txt_ParentPincode.Text != string.Empty)
                {
                    objEWA.ParentPinCode = Convert.ToInt32(txt_ParentPincode.Text);
                }

                objEWA.ParentMobile = txt_PersonalMobile.Text.Trim();
                objEWA.ParentEmail  = txt_ParentEmail.Text.Trim();


                // Panel Last Instituter information

                objEWA.LastClass     = txt_LastAttendedClass.Text.Trim();
                objEWA.ResidentType  = ddl_ResidentType.SelectedItem.ToString();
                objEWA.LastInstitute = txt_LastAttendedClass.Text.Trim();

                objEWA.PassingMonth = ddl_LastExamPassingMonth.SelectedValue.ToString();
                objEWA.PassingYear  = ddl_LastExamPassingYear.SelectedItem.ToString();
                objEWA.Result1      = txt_Result.Text.Trim();
                objEWA.Percentage1  = txt_Percentage.Text.Trim();

                objEWA.Gap1 = ddl_Gap.SelectedItem.ToString();
                objEWA.TcNo = txt_TcNo.Text.Trim();

                objEWA.BankName = txtBankName.Text.Trim();
                if (txt_AccountNo.Text != string.Empty)
                {
                    objEWA.AccountNo = txt_AccountNo.Text.ToString().Trim();
                }

                objEWA.Branch1  = txt_BranchName.Text.Trim();
                objEWA.IFSCCode = txt_IFSCCode.Text.Trim();



                objEWA.StudentUserName = txt_UserName.Text.Trim();

                objEWA.StudentPassword = txt_Password.Text.Trim();

                // Iamage Store
                int    length       = 0;
                byte[] imgSignbyte  = null;
                byte[] imgPhotobyte = null;

                if (fileupload_StudentPhoto.HasFile)
                {
                    length       = fileupload_StudentPhoto.PostedFile.ContentLength;
                    imgPhotobyte = new byte[length];
                    HttpPostedFile img1 = fileupload_StudentPhoto.PostedFile;
                    img1.InputStream.Read(imgPhotobyte, 0, length);
                    ViewState["StudentPhoto"] = imgPhotobyte;
                }

                objEWA.StudentPhoto = (byte[])ViewState["StudentPhoto"];;

                if (fileupload_StudentSign.HasFile)
                {
                    length      = fileupload_StudentSign.PostedFile.ContentLength;
                    imgSignbyte = new byte[length];
                    HttpPostedFile img1 = fileupload_StudentSign.PostedFile;
                    img1.InputStream.Read(imgSignbyte, 0, length);
                    ViewState["StudentSign"] = imgSignbyte;
                }
                //objEWA.StudentSign = (byte[])ViewState["StudentSign"];


                objEWA.StudentUserName = txt_UserName.Text;

                objEWA.StudentPassword = txt_Password.Text;

                objEWA.Status = "Pending";

                int flag = objBAL.InsertInto(objEWA);

                if (flag > 0)
                {
                    if (strAction == "Save")
                    {
                        msgBox.ShowMessage("Form Sumitted  Successfully Check Your Mail  !!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull);
                        string strSMS   = null;
                        string strEmail = null;

                        msgBox.ShowMessage(strSMS, "Saved", UserControls.MessageBox.MessageStyle.Successfull);
                        strEmail = SendEmails();
                        msgBox.ShowMessage(strEmail, "Saved", UserControls.MessageBox.MessageStyle.Successfull);

                        Response.Redirect("~/College_Home.aspx");
                    }
                    else if (strAction == "Update")
                    {
                        msgBox.ShowMessage("Record Updated Successfully !!!", "Updated", UserControls.MessageBox.MessageStyle.Successfull);
                    }
                    else if (strAction == "Delete")
                    {
                        msgBox.ShowMessage("Record Deleted Successfully !!!", "Deleted", UserControls.MessageBox.MessageStyle.Successfull);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Allows you to load a specific record of the [Job] table.
        /// </summary>
        /// <param name="col_JobId">Update this description in the &quot;Olymars/Description&quot; extended property of the &quot;JobId&quot; column.</param>
        public bool Refresh(System.Data.SqlTypes.SqlInt32 col_JobId)
        {
            bool Status;

            Reset();

            if (col_JobId.IsNull)
            {
                throw new ArgumentNullException("col_JobId", "The primary key 'col_JobId' can not have a Null value!");
            }


            this.col_JobId = col_JobId;

            this.Param.Reset();

            this.Param.Param_JobId = this.col_JobId;

            System.Data.SqlClient.SqlDataReader DR;
            SPs.spS_Job SP = new SPs.spS_Job(false);

            if (SP.Execute(ref this.Param, out DR))
            {
                Status = false;
                if (DR.Read())
                {
                    if (!DR.IsDBNull(SPs.spS_Job.Resultset1.Fields.Column_Description.ColumnIndex))
                    {
                        this.col_Description = DR.GetSqlString(SPs.spS_Job.Resultset1.Fields.Column_Description.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Job.Resultset1.Fields.Column_Price.ColumnIndex))
                    {
                        this.col_Price = DR.GetSqlMoney(SPs.spS_Job.Resultset1.Fields.Column_Price.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Job.Resultset1.Fields.Column_StartDate.ColumnIndex))
                    {
                        this.col_StartDate = DR.GetSqlDateTime(SPs.spS_Job.Resultset1.Fields.Column_StartDate.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Job.Resultset1.Fields.Column_EndDate.ColumnIndex))
                    {
                        this.col_EndDate = DR.GetSqlDateTime(SPs.spS_Job.Resultset1.Fields.Column_EndDate.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Job.Resultset1.Fields.Column_CustomerId.ColumnIndex))
                    {
                        this.col_CustomerId = DR.GetSqlInt32(SPs.spS_Job.Resultset1.Fields.Column_CustomerId.ColumnIndex);
                    }

                    Status = true;
                }

                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                return(Status);
            }

            else
            {
                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                throw new Bob.DataClasses.CustomException(this.Param, "Bob.AbstractClasses.Abstract_Job", "Refresh");
            }
        }
Beispiel #22
0
 /// <summary>
 /// Allows you to reset the pre-selected value for the 'EndDate' column.
 /// </summary>
 public void ResetValue_EndDate()
 {
     this.hasBeenPopulated_EndDate = false;
     this.internal_EndDate         = System.Data.SqlTypes.SqlDateTime.Null;
 }
Beispiel #23
0
 /// <summary>
 /// Allows you to reset the pre-selected value for the 'Ord_DatOrderedOn' column.
 /// </summary>
 public void ResetValue_Ord_DatOrderedOn()
 {
     this.hasBeenPopulated_Ord_DatOrderedOn = false;
     this.internal_Ord_DatOrderedOn         = System.Data.SqlTypes.SqlDateTime.Null;
 }
Beispiel #24
0
        private static void getCustomTableFields(string tableName, out List<string> columns, out List<object> values, List<string> currentColumns, List<object> currentValues)
        {
            columns = currentColumns.ToList();
            values = currentValues.ToList();

            Hashtable fields = ApplicationConfiguration.Instance.GetValueByPath<Hashtable>("mappingConfiguration.customDataFields");
            Hashtable _currentDataRow = null;
            foreach (DictionaryEntry htRow in fields)
            {
                _currentDataRow = (Hashtable)htRow.Value;

                if (!_currentDataRow["AdditionalColumnOwner"].ToString().Equals(tableName))
                    continue;

                columns.Add('`' + _currentDataRow["AdditionalFieldColumnName"].ToString() + '`');

                switch (_currentDataRow["AdditionalFieldColumnValue"].ToString())
                {
                    case "DT":
                        {
                            System.Data.SqlTypes.SqlDateTime dt = new System.Data.SqlTypes.SqlDateTime(DateTime.Now);

                            values.Add("'" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + "'");
                            break;
                        }
                    case "D":
                        {
                            values.Add("'" + DateTime.Now.ToShortDateString() + "'");
                            break;
                        }
                    case "T":
                        {
                            values.Add("'" + DateTime.Now.ToShortTimeString() + "'");
                            break;
                        }
                    default:
                        {
                            values.Add("'" + _currentDataRow["AdditionalFieldColumnValue"].ToString() + "'");
                            break;
                        }
                }

            }
        }
Beispiel #25
0
        public static bool Insert_DC_Details(Int32 SOID, string Dc_No, DateTime DC_Date, Int32 NameOfTheTransp, Int32 DispatchDetails, System.Data.SqlTypes.SqlDateTime DispatchDate, System.Data.SqlTypes.SqlDateTime DateOfDelivery, System.Data.SqlTypes.SqlDateTime DateOfInstallation, Int32 EnteredBy)
        {
            // get a configured DbCommand object
            DbCommand comm = DBLayer.CreateCommand();

            // set the stored procedure name
            comm.CommandText = "USB_Insert_DC_Details";
            // create a new parameter
            DbParameter param = comm.CreateParameter();

            param.ParameterName = "@So_ID";
            param.Value         = SOID;
            param.DbType        = DbType.Int32;
            comm.Parameters.Add(param);

            // create a new parameter
            param = comm.CreateParameter();
            param.ParameterName = "@Dc_No";
            param.Value         = Dc_No;
            param.DbType        = DbType.String;
            comm.Parameters.Add(param);


            // create a new parameter
            param = comm.CreateParameter();
            param.ParameterName = "@DC_Date";
            param.Value         = DC_Date;
            param.DbType        = DbType.DateTime;
            comm.Parameters.Add(param);


            // create a new parameter
            param = comm.CreateParameter();
            param.ParameterName = "@NameOfTheTransp";
            param.Value         = NameOfTheTransp;
            param.DbType        = DbType.Int32;
            comm.Parameters.Add(param);

            // create a new parameter
            param = comm.CreateParameter();
            param.ParameterName = "@DispatchDetails";
            param.Value         = DispatchDetails;
            param.DbType        = DbType.Int32;
            comm.Parameters.Add(param);


            // create a new parameter
            param = comm.CreateParameter();
            param.ParameterName = "@DispatchDate";
            param.Value         = DispatchDate;
            param.DbType        = DbType.DateTime;
            comm.Parameters.Add(param);


            // create a new parameter
            param = comm.CreateParameter();
            param.ParameterName = "@DateOfDelivery";
            param.Value         = DateOfDelivery;
            param.DbType        = DbType.DateTime;
            comm.Parameters.Add(param);

            // create a new parameter
            param = comm.CreateParameter();
            param.ParameterName = "@DateOfInstallation";
            param.Value         = DateOfInstallation;
            param.DbType        = DbType.DateTime;
            comm.Parameters.Add(param);

            // create a new parameter
            param = comm.CreateParameter();
            param.ParameterName = "@EnteredBy";
            param.Value         = EnteredBy;
            param.DbType        = DbType.Int32;
            comm.Parameters.Add(param);

            // result will represent the number of changed rows
            int result = -1;

            try
            {
                // execute the stored procedure
                result = DBLayer.ExecuteNonQuery(comm);
            }
            catch
            {
                // any errors are logged in DataAccess
            }
            // result will be 1 in case of success
            return(result != -1);
        }
Beispiel #26
0
 /// <summary>
 /// Allows you to pre-select a value for the 'Ord_DatOrderedOn' column.
 /// </summary>
 public void SetValue_Ord_DatOrderedOn(System.Data.SqlTypes.SqlDateTime value)
 {
     this.hasBeenPopulated_Ord_DatOrderedOn = true;
     this.internal_Ord_DatOrderedOn         = value;
 }
        /// <summary>
        /// Allows you to load a specific record of the [tblOrder] table.
        /// </summary>
        /// <param name="col_Ord_GuidID">Update this description in the &quot;Olymars/Description&quot; extended property of the &quot;Ord_GuidID&quot; column.</param>
        public bool Refresh(System.Data.SqlTypes.SqlGuid col_Ord_GuidID)
        {
            bool Status;

            Reset();

            if (col_Ord_GuidID.IsNull)
            {
                throw new ArgumentNullException("col_Ord_GuidID", "The primary key 'col_Ord_GuidID' can not have a Null value!");
            }


            this.col_Ord_GuidID = col_Ord_GuidID;

            this.Param.Reset();

            this.Param.Param_Ord_GuidID = this.col_Ord_GuidID;

            System.Data.SqlClient.SqlDataReader DR;
            SPs.spS_tblOrder SP = new SPs.spS_tblOrder(false);

            if (SP.Execute(ref this.Param, out DR))
            {
                Status = false;
                if (DR.Read())
                {
                    if (!DR.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_DatOrderedOn.ColumnIndex))
                    {
                        this.col_Ord_DatOrderedOn = DR.GetSqlDateTime(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_DatOrderedOn.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_LngCustomerID.ColumnIndex))
                    {
                        this.col_Ord_LngCustomerID = DR.GetSqlInt32(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_LngCustomerID.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_CurTotal.ColumnIndex))
                    {
                        this.col_Ord_CurTotal = DR.GetSqlMoney(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_CurTotal.ColumnIndex);
                    }

                    Status = true;
                }

                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                return(Status);
            }

            else
            {
                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                throw new OlymarsDemo.DataClasses.CustomException(this.Param, "OlymarsDemo.AbstractClasses.Abstract_tblOrder", "Refresh");
            }
        }
Beispiel #28
0
        private bool IsValidSqlDateTimeNative(string someval)
        {
            bool valid = false;
            DateTime testDate = DateTime.MinValue;
            System.Data.SqlTypes.SqlDateTime sdt;
            if (DateTime.TryParse(someval, out testDate))
            {
                try
                {
                    // take advantage of the native conversion
                    sdt = new System.Data.SqlTypes.SqlDateTime(testDate);
                    valid = true;
                }
                catch (System.Data.SqlTypes.SqlTypeException ex)
                {

                    // no need to do anything, this is the expected out of range error
                }
            }

            return valid;
        }
Beispiel #29
0
 /// <summary>
 /// Allows you to pre-select a value for the 'EndDate' column.
 /// </summary>
 public void SetValue_EndDate(System.Data.SqlTypes.SqlDateTime value)
 {
     this.hasBeenPopulated_EndDate = true;
     this.internal_EndDate         = value;
 }