Beispiel #1
0
        private void btn_SaveCurrentSetting_Click(object sender, EventArgs e)
        {
            int cnt = -1;

            try
            {
                if (m_bInportExcelTabpage_Flag)
                {
                    for (int rows_idx = 0; rows_idx < dgv_ToleranceSetting.Rows.Count - 1; rows_idx++) // rows的数量会比实际数量多1个
                    {
                        B515_Standard_Tolerance[2 * rows_idx]     = Convert.ToDouble(this.dataGridView1.Rows[rows_idx].Cells[3].Value.ToString());
                        B515_Standard_Tolerance[2 * rows_idx + 1] = Convert.ToDouble(this.dataGridView1.Rows[rows_idx].Cells[4].Value.ToString());
                    }
                    // 需保证保存的数值为数字


                    string currentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    // 获取到公差数据,存数据库
                    string CarType = "ACA";
                    cnt = DBOperate_Obj.Insert_ToleranceStandard_ModifiedDat(CarType,
                                                                             DateTime.Now,
                                                                             B515_Standard_Tolerance);
                }
                else
                {
                    for (int rows_idx = 0; rows_idx < dgv_ToleranceSetting.Rows.Count - 1; rows_idx++) // rows的数量会比实际数量多1个
                    {
                        B515_Standard_Tolerance[2 * rows_idx]     = Convert.ToDouble(this.dgv_ToleranceSetting.Rows[rows_idx].Cells[3].Value.ToString());
                        B515_Standard_Tolerance[2 * rows_idx + 1] = Convert.ToDouble(this.dgv_ToleranceSetting.Rows[rows_idx].Cells[4].Value.ToString());
                    }
                    // 需保证保存的数值为数字


                    string currentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    // 获取到公差数据,存数据库
                    string CarType = "ACA";
                    cnt = DBOperate_Obj.Insert_ToleranceStandard_ModifiedDat(CarType,
                                                                             DateTime.Now,
                                                                             B515_Standard_Tolerance);

                    if (cnt == 0)
                    {
                    }
                    else if (cnt == 1)
                    {
                    }
                    else if (cnt == -1)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("1.异常来源:" + ex.Message + "\n2.系统分析:保存当前标准公差数据到数据库异常:\n请检查:\n\t1).保存的标准公差数据是否存在非法字符;\n\t2).数据库是否正常开启"
                                , "异常");
            }
            //
        }