Ejemplo n.º 1
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (spinEdit1.Text == "")
            {
                MessageBox.Show("分类名不能空");
                return;
            }
            //if ( textBox1.Text == "")
            // {
            //      MessageBox.Show("表达式不能空");
            //     return;
            // }
            //if ( textBox2.Text == "")
            //{
            //    MessageBox.Show("保留小数点位数不能空");
            //    return;
            //}
            if (textBox2.Text == "")
            {
                SaveDecimalPoint = 2;
                textBox2.Text    = "2";
            }
            else
            {
                SaveDecimalPoint = Convert.ToInt32(textBox2.Text);
            }
            if (SaveDecimalPoint > 15)
            {
                SaveDecimalPoint = 15;
                textBox2.Text    = "15";
            }


            ExpressionCalculator calc = new ExpressionCalculator();

            StrExpressiontemp = calc.CharConverter(calc.CharConverter(textBox1.Text));
            textBox1.Text     = StrExpressiontemp;
            if (!calc.GetColumnExit(gridView1, calc.CharConverter(spinEdit1.Text), filedname))
            {
                MessageBox.Show("列名" + spinEdit1.Text + "已存在或包含括号[],请重命名");
                return;
            }


            if (!calc.ExpressiontempISIllegal(StrExpressiontemp, gridView1, false, -1))
            {
                return;
            }
            StrExpressiontemp = textBox1.Text;
            caption           = calc.CharConverter(spinEdit1.Text);
            SaveDecimalpoint  = Convert.ToInt32(textBox2.Text);
            this.DialogResult = DialogResult.OK;
        }
Ejemplo n.º 2
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            string strExpression = "";

            if (textBox1.Text == "")
            {
                MessageBox.Show("表达式不能为空");
                return;
            }

            if (textBox2.Text == "")
            {
                textBox2.Text    = "2";
                SaveDecimalpoint = 2;
            }
            else
            {
                SaveDecimalPoint = Convert.ToInt32(textBox2.Text);
                if (SaveDecimalPoint < 0)
                {
                    SaveDecimalPoint = 2;
                    textBox2.Text    = "2";
                }
                else
                if (SaveDecimalPoint > 15)
                {
                    SaveDecimalPoint = 15;
                    textBox2.Text    = "15";
                }
            }

            ExpressionCalculator calc = new ExpressionCalculator();


            strExpression = calc.CharConverter(textBox1.Text);
            textBox1.Text = strExpression;



            if (!calc.ExpressiontempISIllegal(strExpression, gridView1, true, SaveDecimalPoint))
            {
                return;
            }
        }
Ejemplo n.º 3
0
        private void InsertSubstation_Info()
        {
            //LayoutList ll1 = this.ctrlLayoutList1.FocusedObject;
            //if (ll1 == null)
            //    return;

            string columnname = "";

            try
            {
                DataTable dts = new DataTable();
                OpenFileDialog op = new OpenFileDialog();
                op.Filter = "Excel�ļ�(*.xls)|*.xls";
                if (op.ShowDialog() == DialogResult.OK)
                {
                    dts = GetExcel(op.FileName);
                    string str = "";
                    IList<Substation_Info> lii = new List<Substation_Info>();
                    DateTime s8 = DateTime.Now;
                    int x=0;
                    str = "";
                    for (int i = 0; i < dts.Rows.Count; i++)
                    {

                        if (dts.Rows[i][1].ToString().IndexOf("�ϼ�") >= 0)
                            continue;

                        if (dts.Rows[i]["Title"].ToString() == "500ǧ��" || dts.Rows[i]["Title"].ToString() == "220ǧ��" || dts.Rows[i]["Title"].ToString() == "110ǧ������" || dts.Rows[i]["Title"].ToString() == "110ǧ��ר��")
                        {
                            if (dts.Rows[i]["Title"].ToString() == "110ǧ��ר��")
                            {
                                str = "ר��";
                            }
                            else if (dts.Rows[i]["Title"].ToString() == "110ǧ������")
                                str = "����";
                            else
                                str = "";
                            //continue;
                        }
                        try
                        {
                            int.Parse(dts.Rows[i]["S3"].ToString());
                        }
                        catch
                        {
                            continue;
                        }
                        Substation_Info l1 = new Substation_Info();
                        foreach (DataColumn dc in dts.Columns)
                        {
                            columnname = dc.ColumnName;
                            if (dts.Rows[i][dc.ColumnName].ToString() == "" )
                                continue;

                            switch (dc.ColumnName)
                            {
                                case "L2":
                                case "L9":
                                    double LL2 = 0;
                                    try
                                    {
                                        LL2 = Convert.ToDouble(dts.Rows[i][dc.ColumnName].ToString());
                                    }
                                    catch { }
                                    l1.GetType().GetProperty(dc.ColumnName).SetValue(l1, LL2, null);
                                    break;

                                case "L10":
                                    double L10 = 0;
                                    try
                                    {
                                        L10 = ChangeDou(dts.Rows[i][dc.ColumnName].ToString());
                                    }
                                    catch { }
                                    l1.GetType().GetProperty(dc.ColumnName).SetValue(l1, L10, null);
                                    break;
                                case "L1":
                                case "L3":
                                    int LL3 = 0;
                                    try
                                    {
                                        LL3 = Convert.ToInt32(dts.Rows[i][dc.ColumnName].ToString());
                                    }
                                    catch { }
                                    l1.GetType().GetProperty(dc.ColumnName).SetValue(l1, LL3, null);
                                    break;

                                default:
                                    l1.GetType().GetProperty(dc.ColumnName).SetValue(l1, dts.Rows[i][dc.ColumnName].ToString(), null);
                                    break;
                            }
                        }
                        l1.S4 = str;
                        l1.Flag = selectid;
                        l1.CreateDate = s8.AddSeconds(i);
                        l1.AreaID = ProjectUID;
                        lii.Add(l1);
                    }

                    foreach (Substation_Info lll in lii)
                    {
                        Substation_Info l1 = new Substation_Info();
                        //l1.UID += "|" + ProjectUID;
                        l1.AreaName = lll.AreaName;
                        l1.Title = lll.Title;
                        l1.AreaID = ProjectUID;
                        l1.Flag = selectid;
                        try
                        {
                            int tx = int.Parse(l1.S2);
                            if (tx > DateTime.Now.Year)
                                l1.Flag = "2";
                            else
                                l1.Flag = "1";
                        }
                        catch { l1.Flag = "1"; }
                        string con = "AreaID='" + ProjectUID + "' and Title='" + l1.Title + "' and Flag='" + selectid + "'";
                        object obj = Services.BaseService.GetObject("SelectSubstation_InfoByCon", con);

                        ExpressionCalculator ca = new ExpressionCalculator();
                        if (lll.L4 != "")
                        {
                            if (ca.ISIllegal(ca.CharConverter(lll.L4)))
                            {
                                lll.L2 = ca.Calculator(ca.CharConverter(lll.L4), 2);
                            }
                        }
                        if (obj != null)
                        {
                            lll.UID = ((Substation_Info)obj).UID;

                            Services.BaseService.Update<Substation_Info>(lll);
                        }
                        else
                        {
                            lll.UID += "|" + ProjectUID;
                            Services.BaseService.Create<Substation_Info>(lll);
                        }
                    }
                    this.ctrlSubstation_Info1.CalcTotal();
                }
            }
            catch (Exception ex) { MsgBox.Show(columnname + ex.Message); MsgBox.Show("�����ʽ����ȷ��"); }
        }
Ejemplo n.º 4
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            string strExpression = "";
            if (textBox1.Text == "")
            {
                MessageBox.Show("表达式不能为空");
                return;
            }

            if (textBox2.Text == "")
            {
                textBox2.Text = "2";
                SaveDecimalpoint = 2;

            }
            else
            {
                SaveDecimalPoint = Convert.ToInt32(textBox2.Text);
                if (SaveDecimalPoint < 0)
                {
                    SaveDecimalPoint = 2;
                    textBox2.Text = "2";
                }
                else
                    if (SaveDecimalPoint > 15)
                    {
                        SaveDecimalPoint = 15;
                        textBox2.Text = "15";
                    }
            }

            ExpressionCalculator calc = new ExpressionCalculator();

            strExpression = calc.CharConverter(textBox1.Text);
            textBox1.Text = strExpression;

            if (!calc.ExpressiontempISIllegal(strExpression, gridView1, true, SaveDecimalPoint))
                return;
        }
Ejemplo n.º 5
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (spinEdit1.Text == "")
            {
                MessageBox.Show("分类名不能空");
                return;
            }
               //if ( textBox1.Text == "")
               // {
               //      MessageBox.Show("表达式不能空");
               //     return;
               // }
               //if ( textBox2.Text == "")
               //{
               //    MessageBox.Show("保留小数点位数不能空");
               //    return;
               //}
            if (textBox2.Text=="")
            {
                SaveDecimalPoint = 2;
                textBox2.Text = "2";
            }
            else
                {
                    SaveDecimalPoint=Convert.ToInt32(textBox2.Text);

                }
               if(SaveDecimalPoint>15)
               {
                   SaveDecimalPoint = 15;
                   textBox2.Text = "15";
               }

               ExpressionCalculator calc = new ExpressionCalculator();
               StrExpressiontemp = calc.CharConverter(calc.CharConverter(textBox1.Text));
               textBox1.Text = StrExpressiontemp;
               if (!calc.GetColumnExit(gridView1, calc.CharConverter(spinEdit1.Text),filedname))
               {
               MessageBox.Show("列名" + spinEdit1.Text + "已存在或包含括号[],请重命名");
               return;
               }

               if (!calc.ExpressiontempISIllegal(StrExpressiontemp, gridView1, false, -1))
               return;
               StrExpressiontemp = textBox1.Text;
               caption =calc.CharConverter(spinEdit1.Text) ;
               SaveDecimalpoint = Convert.ToInt32(textBox2.Text);
               this.DialogResult = DialogResult.OK;
        }
        protected bool SaveRecord()
        {
            try
            {
                ExpressionCalculator ca = new ExpressionCalculator();
                if (_obj.L4 != "")
                {
                    if (ca.ISIllegal(ca.CharConverter(_obj.L4)))
                    {
                        _obj.L2 = ca.Calculator(ca.CharConverter(_obj.L4), 2);
                    }
                }

                if (_obj.L13 != "0")
                    _obj.S6 = string.Format("{0:f}", double.Parse(_obj.L14) * 100 / double.Parse(_obj.L13));

            }
            catch { }
            if (_obj.L2 != 0)
                _obj.L10 = _obj.L9*100 / _obj.L2;

            try
            {
                int x = int.Parse(_obj.S2);
                if (x > DateTime.Now.Year)
                    _obj.Flag = "2";
                else
                    _obj.Flag = "1";
            }
            catch { _obj.Flag = "1"; }

            //����/�޸� ����
               // _obj.L30 = projectid;
            try
            {
                _obj.AreaID = projectid;
                if (IsCreate)
                {
                    _obj.UID += "|" + projectid;
                    Services.BaseService.Create<Substation_Info>(_obj);
                }
                else
                {
                    Services.BaseService.Update<Substation_Info>(_obj);
                }

            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return false ;
            }

            //�����ѳɹ�
            return true;
        }
        protected bool SaveRecord()
        {
            try
            {
                ExpressionCalculator ca = new ExpressionCalculator();
                if (_obj.L4 != "")
                {
                    if (ca.ISIllegal(ca.CharConverter(_obj.L4)))
                    {
                        _obj.L2 = ca.Calculator(ca.CharConverter(_obj.L4), 2);
                    }
                }

                if (_obj.L13 != "0")
                {
                    _obj.S6 = string.Format("{0:f}", double.Parse(_obj.L14) * 100 / double.Parse(_obj.L13));
                }
            }
            catch { }
            if (_obj.L2 != 0)
            {
                _obj.L10 = _obj.L9 * 100 / _obj.L2;
            }

            try
            {
                int x = int.Parse(_obj.S2);
                if (x > DateTime.Now.Year)
                {
                    _obj.Flag = "2";
                }
                else
                {
                    _obj.Flag = "1";
                }
            }
            catch { _obj.Flag = "1"; }

            //创建/修改 对象
            // _obj.L30 = projectid;
            try
            {
                _obj.AreaID = projectid;
                if (IsCreate)
                {
                    _obj.UID += "|" + projectid;
                    Services.BaseService.Create <Substation_Info>(_obj);
                }
                else
                {
                    Services.BaseService.Update <Substation_Info>(_obj);
                }
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return(false);
            }

            //操作已成功
            return(true);
        }