Esempio n. 1
0
        /// <summary>
        /// 保存按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Save_Click(object sender, EventArgs e)
        {
            if (this.dataGridView_Main.Rows.Count == 0)
            {
                return;
            }

            List <Radar> list = new List <Radar>();

            foreach (DataGridViewRow row in this.dataGridView_Main.Rows)
            {
                //找到新增或修改行
                if (row.Cells["Column_Id"].Value.ToString().Equals("0") || row.Cells["Column_Changed"].Value.ToString().Equals("1"))
                {
                    Radar radar = DataGridViewUtil.ConvertDataGridViewRow2Obect <Radar>(row, false);                       //不抛出异常
                    radar.ConnectionMode = (ConnectionMode)int.Parse(row.Cells["Column_ConnectionMode"].Value.ToString()); //连接模式
                    radar.Direction      = (Directions)int.Parse(row.Cells["Column_Direction"].Value.ToString());          //单独处理雷达朝向字段
                    if (radar.OwnerGroupId > 0)
                    {
                        list.Add(radar);
                    }
                    else
                    {
                        MessageBox.Show("所属雷达组不得为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
            }

            bool result;

            try { result = this.dataService.SaveRadars(list); }
            catch (Exception ex)
            {
                string errorMessage = "雷达信息保存时出现问题:" + ex.Message;
                MessageBox.Show(errorMessage, "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (result)
            {
                MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DataSourceRefresh();
            }
            else
            {
                MessageBox.Show("保存失败", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// 保存按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Save_Click(object sender, EventArgs e)
        {
            if (this.dataGridView_Main.Rows.Count == 0)
            {
                return;
            }

            List <RadarGroup> list = new List <RadarGroup>();

            foreach (DataGridViewRow row in this.dataGridView_Main.Rows)
            {
                if (row.Cells["Column_Id"].Value.ToString().Equals("0") || row.Cells["Column_Changed"].Value.ToString().Equals("1"))
                {
                    RadarGroup group = DataGridViewUtil.ConvertDataGridViewRow2Obect <RadarGroup>(row);
                    if (group.OwnerShiploaderId > 0)
                    {
                        list.Add(group);
                    }
                    else
                    {
                        MessageBox.Show("所属装船机不得为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
            }

            bool result;

            try { result = this.dataService.SaveRadarGroups(list); }
            catch (Exception ex)
            {
                string errorMessage = "雷达组信息保存时出现问题:" + ex.Message;
                MessageBox.Show(errorMessage, "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (result)
            {
                MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DataSourceRefresh();
            }
            else
            {
                MessageBox.Show("保存失败", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 保存按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Save_Click(object sender, EventArgs e)
        {
            if (this.dataGridView.Rows.Count == 0)
            {
                return;
            }

            List <Radar> list = new List <Radar>();

            foreach (DataGridViewRow row in this.dataGridView.Rows)
            {
                if (row.Cells["Column_Changed"].Value.ToString().Equals("1"))
                {
                    Radar radar = DataGridViewUtil.ConvertDataGridViewRow2Obect <Radar>(row, false); //不抛出异常
                    radar.RadarCoorsLimited   = row.Cells["Column_RadarCoorsLimited"].Value.ToString().Equals("1");
                    radar.ClaimerCoorsLimited = row.Cells["Column_ClaimerCoorsLimited"].Value.ToString().Equals("1");
                    list.Add(radar);
                }
            }

            bool result;

            try { result = this.dataService.SaveRadarCoorsLimitations(list); }
            catch (Exception ex)
            {
                string errorMessage = "信息保存时出现问题:" + ex.Message;
                MessageBox.Show(errorMessage, "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (result)
            {
                MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DataSourceRefresh();
            }
            else
            {
                MessageBox.Show("保存失败", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// 保存按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Save_Click(object sender, EventArgs e)
        {
            if (this.dataGridView_Main.Rows.Count == 0)
            {
                return;
            }

            List <Shiploader> list = new List <Shiploader>();

            foreach (DataGridViewRow row in this.dataGridView_Main.Rows)
            {
                if (row.Cells["Column_Id"].Value.ToString().Equals("0") || row.Cells["Column_Changed"].Value.ToString().Equals("1"))
                {
                    list.Add(DataGridViewUtil.ConvertDataGridViewRow2Obect <Shiploader>(row));
                }
            }

            bool result;

            try { result = this.dataService.SaveShiploaders(list); }
            catch (Exception ex)
            {
                string errorMessage = "装船机信息保存时出现问题:" + ex.Message;
                MessageBox.Show(errorMessage, "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //假如返回true或没有修改行
            if (result || list.Count == 0)
            {
                MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DataSourceRefresh();
            }
            else
            {
                MessageBox.Show("保存失败", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }