Ejemplo n.º 1
0
        public static object IsNullCheck(object obj, datatypes ObjectType = datatypes.vartypestring)
        {
            object objReturn = null;

            objReturn = obj;
            if (ObjectType == datatypes.vartypestring & (Information.IsDBNull(obj) || obj == null))
            {
                objReturn = "";
            }
            else if (ObjectType == datatypes.vartypenumeric)
            {
                if (Information.IsDBNull(obj) == true)
                {
                    objReturn = 0;
                }
                else if (Information.IsNumeric(obj) == false)
                {
                    objReturn = 0;
                }
                else if (obj.ToString() == "")
                {
                    objReturn = 0;
                }
            }
            else if (ObjectType == datatypes.VarTypeDate)
            {
                if (Information.IsDBNull(obj) == true)
                {
                    objReturn = DateTime.MinValue;
                }
                else if (Information.IsDate(obj) == false)
                {
                    objReturn = DateTime.MinValue;
                }
                else if (Convert.ToDateTime(obj) == DateTime.MinValue)
                {
                    objReturn = DateTime.MinValue;
                }
            }
            else if (ObjectType == datatypes.varTypeBoolean & Information.IsDBNull(obj))
            {
                objReturn = false;
            }
            return(objReturn);
        }
Ejemplo n.º 2
0
    public static object IsNullCheck(object obj, datatypes ObjectType = datatypes.vartypestring)
    {
        object objReturn = null;

        objReturn = obj;
        if (ObjectType == datatypes.vartypestring & Information.IsDBNull(obj))
        {
            objReturn = "";
        }
        else if (ObjectType == datatypes.vartypenumeric)
        {
            if (Information.IsDBNull(obj) == true)
            {
                objReturn = 0;
            }
            else if (Information.IsNumeric(obj) == false)
            {
                objReturn = 0;
            }
        }
        else if (ObjectType == datatypes.VarTypeDate)
        {
            if (Information.IsDBNull(obj) == true)
            {
                objReturn = DateTime.Now;
            }
            else if (Information.IsDate(obj) == false)
            {
                objReturn = DateTime.Now;
            }
        }
        else if (ObjectType == datatypes.varTypeBoolean & Information.IsDBNull(obj))
        {
            objReturn = false;
        }
        return(objReturn);
    }
        private void okpanel_click(object sender, EventArgs e)
        {
            this.panel4.BackColor = System.Drawing.Color.Gray;
            datatypes dt = new datatypes();

            // check if values passed are indeed valid
            if (fdlg.FileName != null && this.richTextBox1 != null && this.richTextBox3 != null)
            {
                bool result = int.TryParse(this.richTextBox1.Text, out int frequency);
                if (frequency > 0)
                {
                    switch (comboBox1)
                    {
                    case "Minutes":
                        dt.unitoftime = "Minutes";
                        break;

                    case "Seconds":
                        dt.unitoftime = "Seconds";
                        break;

                    case "Hours":
                        dt.unitoftime = "Hours";
                        break;

                    case "Days":
                        dt.unitoftime = "Days";
                        break;
                    }
                    dt.frequency            = frequency;
                    dt.gdrivefolder         = this.richTextBox3.Text;
                    dt.delete               = false;
                    dt.uploadFileToFolder_0 = true;
                    dt.uploadFileToFolder   = true;
                    dt.createnewfile        = true;
                }
                else
                {
                    result = false;
                }
                if (!result)
                {
                    MessageBox.Show("Something went horribly  wrong in parsing the input values! Line 73");
                }
                try
                {
                    XmlSerializer xml = dt.WriteData("saveload.xml");
                }
                catch (FileNotFoundException)
                {
                    MessageBox.Show("File not Found: \"saveload.ini\"");
                }
                catch (DirectoryNotFoundException)
                {
                    MessageBox.Show("Directory not Found: \"saveload.ini\"");
                }
                catch
                {
                    MessageBox.Show("An Unexpected Error Occured!");
                }
            }
            else
            {
                MessageBox.Show("Enter in a correct parameter!");
            }
            Process.Start("backup.exe");
        }