public virtual void Insert(int rowIndex, DataGridViewRow dataGridViewRow) {}
	public virtual void AddRange(DataGridViewRow[] dataGridViewRows) {}
	public void CopyTo(DataGridViewRow[] array, int index) {}
Esempio n. 4
0
 public SPLookupFormItemSelectedEventArgs(DataGridViewRow FirstItem, DataGridViewSelectedRowCollection SelectedItems)
 {
     this._FirstItem = FirstItem;
     this._SelectedItems = SelectedItems;
 }
	// Constructors
	public DataGridViewRowEventArgs(DataGridViewRow dataGridViewRow) {}
Esempio n. 6
0
        void ActualizarMovimientos()
        {
            //Metodo que muestra en dgMovimientos las operaciones realizadas por la maquina

            if (dgMovimiento.Columns.Count == 0)
            {
                dgMovimiento.Columns.Add("No", "No.");
                for (int i = 0; i < maquina.Cadena.Length; i++)
                {
                    dgMovimiento.Columns.Add($"{i}", $"{i}");
                }
                dgMovimiento.Columns.Add("q", "q");
                dgMovimiento.Columns.Add("SL", "SL");
                dgMovimiento.Columns.Add("NS", "NS");
                dgMovimiento.Columns.Add("p", "p");
                dgMovimiento.Columns.Add("Mov", "Mov");
            }
            dgMovimiento.Rows.Clear();
            foreach (Movimiento mov in maquina.Movimientos)
            {
                DataGridViewRow dr = new DataGridViewRow();
                dr.Cells.Add(dataGridViewCell: new DataGridViewTextBoxCell()
                {
                    Value = mov.Paso
                });
                char[] cadena = mov.Cadena.ToCharArray();
                for (int i = 0; i < cadena.Length; i++)
                {
                    DataGridViewCellStyle style = new DataGridViewCellStyle();
                    style.BackColor = i == mov.PosicionCabezal ? Color.Red : Color.White;
                    dr.Cells.Add(dataGridViewCell: new DataGridViewTextBoxCell()
                    {
                        Value = cadena[i], Style = style
                    });
                }
                if (mov.Transicion is null)
                {
                    dr.Cells.Add(dataGridViewCell: new DataGridViewTextBoxCell()
                    {
                        Value = "qf"
                    });
                    dgMovimiento.Rows.Add(dr);
                }
                else
                {
                    dr.Cells.Add(dataGridViewCell: new DataGridViewTextBoxCell()
                    {
                        Value = mov.Transicion.q
                    });
                    dr.Cells.Add(dataGridViewCell: new DataGridViewTextBoxCell()
                    {
                        Value = mov.Transicion.ValorBuscado
                    });
                    dr.Cells.Add(dataGridViewCell: new DataGridViewTextBoxCell()
                    {
                        Value = mov.Transicion.ValorNuevo
                    });
                    dr.Cells.Add(dataGridViewCell: new DataGridViewTextBoxCell()
                    {
                        Value = mov.Transicion.p
                    });
                    dr.Cells.Add(dataGridViewCell: new DataGridViewTextBoxCell()
                    {
                        Value = mov.Transicion.Movimiento.ToString()
                    });
                    dgMovimiento.Rows.Add(dr);
                }
            }
        }
Esempio n. 7
0
        private void Display()
        {
            //DONT turn on sorting in the future, thats not how it works.  You click and drag to sort manually since it gives you
            // the order of recipies.
            List <Tuple <MaterialCommoditiesList.Recipe, int> > wantedList = null;

            if (last_he != null)
            {
                List <MaterialCommodities> mcl = last_he.MaterialCommodity.Sort(false);
                int fdrow = dataGridViewSynthesis.FirstDisplayedScrollingRowIndex;      // remember where we were displaying

                MaterialCommoditiesList.ResetUsed(mcl);

                wantedList = new List <Tuple <MaterialCommoditiesList.Recipe, int> >();

                string        recep       = SQLiteDBClass.GetSettingString(DbRecipeFilterSave, "All");
                string[]      recipeArray = recep.Split(';');
                string        levels      = SQLiteDBClass.GetSettingString(DbLevelFilterSave, "All");
                string[]      lvlArray    = (levels == "All" || levels == "None") ? new string[0] : levels.Split(';');
                string        materials   = SQLiteDBClass.GetSettingString(DbMaterialFilterSave, "All");
                List <string> matList;
                if (materials == "All" || materials == "None")
                {
                    matList = new List <string>();
                }
                else
                {
                    matList = materials.Split(';').Where(x => !string.IsNullOrEmpty(x)).Select(m => matLookUp.Where(u => u.Item2 == m).First().Item1).ToList();
                }

                for (int i = 0; i < SynthesisRecipes.Count; i++)
                {
                    int rno = (int)dataGridViewSynthesis.Rows[i].Tag;
                    dataGridViewSynthesis.Rows[i].Cells[2].Value = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes[rno]).Item1.ToStringInvariant();
                    bool visible = true;

                    if (recep == "All" && levels == "All" && materials == "All")
                    {
                        visible = true;
                    }
                    else
                    {
                        visible = false;
                        if (recep == "All")
                        {
                            visible = true;
                        }
                        else
                        {
                            visible = recipeArray.Contains(SynthesisRecipes[rno].name);
                        }
                        if (levels == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            visible = visible && lvlArray.Contains(SynthesisRecipes[rno].level);
                        }
                        if (materials == "All")
                        {
                            visible = visible && true;
                        }
                        else
                        {
                            var included = matList.Intersect <string>(SynthesisRecipes[rno].ingredients.ToList <string>());
                            visible = visible && included.Count() > 0;
                        }
                    }

                    dataGridViewSynthesis.Rows[i].Visible = visible;
                }

                for (int i = 0; i < SynthesisRecipes.Count; i++)
                {
                    int rno = (int)dataGridViewSynthesis.Rows[i].Tag;
                    if (dataGridViewSynthesis.Rows[i].Visible)
                    {
                        Tuple <int, int, string> res = MaterialCommoditiesList.HowManyLeft(mcl, SynthesisRecipes[rno], Wanted[rno]);
                        //System.Diagnostics.Debug.WriteLine("{0} Recipe {1} executed {2} {3} ", i, rno, Wanted[rno], res.Item2);

                        using (DataGridViewRow row = dataGridViewSynthesis.Rows[i])
                        {
                            row.Cells[3].Value = Wanted[rno].ToStringInvariant();
                            row.Cells[4].Value = res.Item2.ToStringInvariant();
                            row.Cells[5].Value = res.Item3;
                        }
                    }
                    if (Wanted[rno] > 0 && (dataGridViewSynthesis.Rows[i].Visible || isEmbedded))
                    {
                        wantedList.Add(new Tuple <MaterialCommoditiesList.Recipe, int>(SynthesisRecipes[rno], Wanted[rno]));
                    }
                }

                dataGridViewSynthesis.RowCount = SynthesisRecipes.Count;         // truncate previous shopping list..

                if (!isEmbedded)
                {
                    MaterialCommoditiesList.ResetUsed(mcl);
                    List <MaterialCommodities> shoppinglist = MaterialCommoditiesList.GetShoppingList(wantedList, mcl);
                    shoppinglist.Sort(delegate(MaterialCommodities left, MaterialCommodities right) { return(left.name.CompareTo(right.name)); });

                    foreach (MaterialCommodities c in shoppinglist)        // and add new..
                    {
                        Object[] values = { c.name, "", c.scratchpad.ToStringInvariant(), "", c.shortname };
                        int      rn     = dataGridViewSynthesis.Rows.Add(values);
                        dataGridViewSynthesis.Rows[rn].ReadOnly = true;     // disable editing wanted..
                    }
                }

                if (fdrow >= 0 && dataGridViewSynthesis.Rows[fdrow].Visible)        // better check visible, may have changed..
                {
                    dataGridViewSynthesis.FirstDisplayedScrollingRowIndex = fdrow;
                }
            }

            if (OnDisplayComplete != null)
            {
                OnDisplayComplete(wantedList);
            }
        }
 public CellComboBoxEventArgs(int selectedIndex, object selectedObject, int rowIndex, int colIndex, DataGridView listObj = null, DataGridViewRow row = null, DataGridViewComboBoxCell cell = null)
 {
     ListObj        = listObj;
     Row            = row;
     Cell           = cell;
     SelectedIndex  = selectedIndex;
     SelectedObject = selectedObject;
     RowIndex       = rowIndex;
     ColIndex       = colIndex;
 }
Esempio n. 9
0
        /// <summary>
        /// Method that loads bookings in the datagridview.
        /// </summary>
        private void LoadBookings()
        {
            try
            {
                roomId = Convert.ToInt32(cbxRoom.SelectedValue.ToString());
                if (DateTime.Today.DayOfWeek == DayOfWeek.Monday && flagMonday)
                {
                    for (int i = 0; i < bookingListAll.Count; i++)
                    {
                        splitter          = bookingListAll[i].WeekDay.Split(' ');
                        startDateSelected = splitter.Last();
                        startList         = Convert.ToDateTime(startDateSelected);
                        if (startList < DateTime.Today)
                        {
                            bookingBLL.DeleteBooking(bookingListAll[i].Id.ToString());
                        }
                    }
                    flagMonday = false;
                }
                bookingList = Functions.ConvertToList <BookingDTO>(bookingBLL.LoadXML()).Where(x => x.RoomId == roomId).OrderBy(x => Convert.ToDateTime(x.WeekDay)).ThenBy(x => x.StartBookingHour).ToList();

                dgvQuickBookings.Columns.Clear();
                dgvQuickBookings.Columns.Add("Horário", "Horário");
                dgvQuickBookings.ReadOnly = true;

                #region Creating fix columns
                for (int i = 0; i < 2; i++)
                {
                    using (DataGridViewColumn colMonday = new DataGridViewColumn())
                    {
                        colMonday.Name = DateTime.Today.AddDays((-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Monday) + (i * 7)).Day.ToString().PadLeft(2, '0') + "/" +
                                         DateTime.Today.AddDays((-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Monday) + (i * 7)).Month.ToString().PadLeft(2, '0');
                        colMonday.HeaderText = "segunda-feira - " + colMonday.Name;
                        colMonday.Width      = 145;
                        dgvQuickBookings.Columns.Add(colMonday);
                    }
                    using (DataGridViewColumn colTuesday = new DataGridViewColumn())
                    {
                        colTuesday.Name = DateTime.Today.AddDays((-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Tuesday) + (i * 7)).Day.ToString().PadLeft(2, '0') + "/" +
                                          DateTime.Today.AddDays((-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Tuesday) + (i * 7)).Month.ToString().PadLeft(2, '0');
                        colTuesday.HeaderText = "terça-feira - " + colTuesday.Name;
                        colTuesday.Width      = 145;
                        dgvQuickBookings.Columns.Add(colTuesday);
                    }
                    using (DataGridViewColumn colWednesday = new DataGridViewColumn())
                    {
                        colWednesday.Name = DateTime.Today.AddDays((-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Wednesday) + (i * 7)).Day.ToString().PadLeft(2, '0') + "/" +
                                            DateTime.Today.AddDays((-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Wednesday) + (i * 7)).Month.ToString().PadLeft(2, '0');
                        colWednesday.HeaderText = "quarta-feira - " + colWednesday.Name;
                        colWednesday.Width      = 145;
                        dgvQuickBookings.Columns.Add(colWednesday);
                    }
                    using (DataGridViewColumn colThursday = new DataGridViewColumn())
                    {
                        colThursday.Name = DateTime.Today.AddDays((-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Thursday) + (i * 7)).Day.ToString().PadLeft(2, '0') + "/" +
                                           DateTime.Today.AddDays((-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Thursday) + (i * 7)).Month.ToString().PadLeft(2, '0');
                        colThursday.HeaderText = "quinta-feira - " + colThursday.Name;
                        colThursday.Width      = 145;
                        dgvQuickBookings.Columns.Add(colThursday);
                    }
                    using (DataGridViewColumn colFriday = new DataGridViewColumn())
                    {
                        colFriday.Name = DateTime.Today.AddDays((-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Friday) + (i * 7)).Day.ToString().PadLeft(2, '0') + "/" +
                                         DateTime.Today.AddDays((-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Friday) + (i * 7)).Month.ToString().PadLeft(2, '0');
                        colFriday.HeaderText = "sexta-feira - " + colFriday.Name;
                        colFriday.Width      = 145;
                        dgvQuickBookings.Columns.Add(colFriday);
                    }
                }
                #endregion

                #region Creating fix rows

                int ind = 8;
                for (int i = 0; i < 10; i++)
                {
                    int[] columns = new int[11];

                    using (DataGridViewRow row = new DataGridViewRow())
                    {
                        for (int c = 0; c < columns.Length; c++)
                        {
                            row.Cells.Add(new DataGridViewTextBoxCell {
                                Value = (c == 0) ? DateTime.Today.AddHours(ind).ToShortTimeString() : ""
                            });
                        }
                        ind++;
                        dgvQuickBookings.Rows.Add(row);
                    }
                }
                #endregion

                #region Populating cells
                for (int i = 0; i < dgvQuickBookings.Rows.Count; i++)
                {
                    for (int j = 0; j < bookingList.Count; j++)
                    {
                        if (Convert.ToDateTime(bookingList[j].StartBookingHour) <= Convert.ToDateTime(dgvQuickBookings.Rows[i].Cells[0].Value.ToString()) &&
                            Convert.ToDateTime(bookingList[j].EndBookingHour) > Convert.ToDateTime(dgvQuickBookings.Rows[i].Cells[0].Value.ToString()))
                        {
                            for (int k = 1; k < dgvQuickBookings.Rows[i].Cells.Count; k++)
                            {
                                var split = dgvQuickBookings.Columns[k].HeaderText.Split(' ');
                                if (bookingList[j].WeekDay == split.Last().ToString() + "/" + DateTime.Today.Year.ToString())
                                {
                                    dgvQuickBookings.Rows[i].Cells[k].Tag   = bookingList[j].Id;
                                    dgvQuickBookings.Rows[i].Cells[k].Value = bookingList[j].Username;
                                }
                            }
                        }
                    }
                }
                #endregion

                dgvQuickBookings.Columns.Cast <DataGridViewColumn>().ToList().ForEach(f => f.SortMode = DataGridViewColumnSortMode.NotSortable);
                dgvQuickBookings.Columns["Horário"].Frozen = true;
                dgvQuickBookings.Columns["Horário"].Width  = 100;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Erro para montar tabela temporária," + ex.Message, "Mecalux", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 10
0
        private void ChangeGameButton_Click(object sender, EventArgs e)
        {
            Игры game = entity.Игры.FirstOrDefault(a => a.Код_игры == game_id);

            if (GameTitleBox.Text != "")
            {
                game.Игра = GameTitleBox.Text;
            }
            if (GenreBox.Text != "")
            {
                Жанры genre = entity.Жанры.FirstOrDefault(a => a.Жанр == GenreBox.Text);
                game.Жанры = genre;
            }
            if (PlatformBox.Text != "")
            {
                Платформы plarform = entity.Платформы.FirstOrDefault(a => a.Платформа == PlatformBox.Text);
                game.Платформы = plarform;
            }
            if (NewPubl.Checked == true)
            {
                if (PublBox.Text != "" && PublCountry.Text != "")
                {
                    Страны   country = entity.Страны.FirstOrDefault(a => a.Страна == PublCountry.Text);
                    Издатели publ    = new Издатели
                    {
                        Издатели = PublBox.Text,
                        Страны   = country
                    };
                    game.Издатели.Add(publ);
                }
                else
                {
                    MessageBox.Show("Новый издатель не добавлен, так как не все поля заполнены");
                }
            }
            else
            {
                if (PublComboBox.Text != "")
                {
                    DataGridViewRow row = Database.SelectedRows[0];
                    if (row != null)
                    {
                        string   publ_name = row.Cells[7].ToString();
                        Издатели publ      = game.Издатели.FirstOrDefault(a => a.Издатели == publ_name);
                        game.Издатели.Remove(publ);
                    }
                    Издатели newpubl = entity.Издатели.FirstOrDefault(a => a.Издатели == PublComboBox.Text);
                    game.Издатели.Add(newpubl);
                }
            }
            if (Engine.Text != "")
            {
                game.Движок = Engine.Text;
            }
            if (DatetimeGameBox.Value < DateTime.Now)
            {
                game.Дата_создания = DatetimeGameBox.Value;
            }

            if (NewTitleRating.Checked == true)
            {
                if (RatingTitleBox.Text != "" && AgeRatingBox.Text != "")
                {
                    Возрастной_рейтинг rating = new Возрастной_рейтинг
                    {
                        Название_рейтинга = RatingTitleBox.Text,
                        ейтинг            = AgeRatingBox.Text
                    };
                    game.Возрастной_рейтинг.Add(rating);
                }
                else
                {
                    MessageBox.Show("Новый возрастной рейтинг не добавлен, так как не все поля заполнены");
                }
            }
            else
            {
                if (RatingTitleComboBox.Text != "" && AgeRatingComboBox.Text != "")
                {
                    DataGridViewRow row = Database.SelectedRows[0];
                    if (row != null)
                    {
                        string             rating_name = row.Cells[8].ToString();
                        string             rating      = row.Cells[9].ToString();
                        Возрастной_рейтинг r           = game.Возрастной_рейтинг.FirstOrDefault(a => a.Название_рейтинга == rating_name && a.ейтинг == rating);
                        game.Возрастной_рейтинг.Remove(r);
                    }
                    Возрастной_рейтинг newrating = entity.Возрастной_рейтинг.FirstOrDefault(a => a.Название_рейтинга == RatingTitleComboBox.Text && a.ейтинг == AgeRatingComboBox.Text);
                    game.Возрастной_рейтинг.Add(newrating);
                }
            }
            entity.SaveChanges();
            Close();
        }
Esempio n. 11
0
        private void btnSure_Click(object sender, EventArgs e)
        {
            //if (combStandard.Text == "请选择")
            //{
            //    MessageBox.ShowTip("请选择标准配方"); return;
            //}
            //if (comboDevice.Text == "请选择")
            //{
            //    MessageBox.ShowTip("请选择机台"); return;
            //}
            View_DeviceInfoModel deviceModel = deviceInfoModelList.SingleOrDefault(s => s.PotCode == comboPot.SelectedValue.ToString());

            View_FormulaInfoModel formulaDetailModel = new View_FormulaInfoModel();

            DSW_FormulaStandardModel standardModel = standardModelList.SingleOrDefault(s => s.Id == new Guid(combStandard.SelectedValue.ToString()));

            formulaDetailModel.Id                   = Guid.NewGuid();
            formulaDetailModel.BarCode              = DateTime.Now.ToString("yyMMddHHmmss");
            formulaDetailModel.Quantity             = decimal.Parse(lblStandardQuantity.Text);
            formulaDetailModel.StandardQuantity     = decimal.Parse(lblStandardQuantity.Text);
            formulaDetailModel.CylinderNum          = 1;
            formulaDetailModel.DeviceId             = deviceModel.DeviceId;
            formulaDetailModel.DeviceName           = deviceModel.DeviceName;
            formulaDetailModel.DeviceType           = deviceModel.Type;
            formulaDetailModel.PotCode              = deviceModel.PotCode;
            formulaDetailModel.IsManualFeed         = IsChecked;
            formulaDetailModel.Remark               = standardModel.Remark;
            formulaDetailModel.ManufactureOrderId   = Guid.Empty;
            formulaDetailModel.FormulaName          = "手动配送";
            formulaDetailModel.ManufactureOrderCode = "***";
            formulaDetailModel.Customer             = "***";;
            formulaDetailModel.Color                = "***";
            formulaDetailModel.ProductName          = "***";
            formulaDetailModel.ProductSpecification = "***";
            formulaDetailModel.ProductWidth         = "***";
            formulaDetailModel.Meter                = "***";
            formulaDetailModel.LatestDate           = DateTime.Now.AddYears(1);
            formulaDetailModel.Status               = 0;
            formulaDetailModel.ClientIP             = deviceModel.IP;
            formulaDetailModel.CompleteCylinderNum  = 0;
            List <View_FormulaDetailInfoModel> list = new List <View_FormulaDetailInfoModel>();

            for (int i = 0; i < dataView1.Rows.Count; i++)
            {
                DataGridViewRow             dgvr            = dataView1.Rows[i];
                View_FormulaDetailInfoModel detailInfoModel = new View_FormulaDetailInfoModel();
                detailInfoModel.Id               = Guid.NewGuid();
                detailInfoModel.BarCode          = formulaDetailModel.BarCode;
                detailInfoModel.MaterialId       = new Guid(dgvr.Cells["MaterialId"].Value.ToString());
                detailInfoModel.MaterialName     = dgvr.Cells["MaterialName"].Value.ToString();
                detailInfoModel.MaterialCode     = dgvr.Cells["MaterialCode"].Value.ToString();
                detailInfoModel.MaterialQuantity = decimal.Parse(dgvr.Cells["MaterialQuantity"].Value.ToString());
                detailInfoModel.Sort             = i;
                detailInfoModel.Unit             = dgvr.Cells["Unit"].Value.ToString();
                detailInfoModel.Price            = decimal.Parse(dgvr.Cells["Price"].Value.ToString());
                detailInfoModel.DeviceId         = deviceModel.Id;
                list.Add(detailInfoModel);
            }
            formulaDetailModel.list = list;


            if (formulaDetailModel.list.Count == 0)
            {
                MessageBox.ShowTip("请先添加助剂");
                return;
            }
            decimal materialSum         = list.Sum(s => s.MaterialQuantity);
            decimal minStandardQuantity = Golbal.CleanWater + Golbal.IntervalWater * dataView1.RowCount + materialSum;
            decimal maxStandardQuantity = deviceModel.StandardQuantity.Value;

            if (decimal.Parse(lblStandardQuantity.Text) < minStandardQuantity)
            {
                MessageBox.ShowTip("机台缸量不能小于" + minStandardQuantity + ""); return;
            }
            if (decimal.Parse(lblStandardQuantity.Text) > maxStandardQuantity)
            {
                MessageBox.ShowTip("机台缸量不能大于" + maxStandardQuantity + ""); return;
            }

            try
            {
                Golbal.MyQueueList.Add(formulaDetailModel);

                MessageBox.ShowTip("添加到队列成功");
            }
            catch
            {
                MessageBox.ShowTip("添加到队列失败");
            }
        }
Esempio n. 12
0
        private void updateForm()
        {
            txtCivilName.Text   = human.name;
            chkIsMale.Checked   = human.isMale;
            chkIsAlive.Checked  = human.isAlive;
            txtDateOfBirth.Text = human.dateOfBirth.ToLongDateString();
            txtAge.Text         = ((int)Math.Round(human.age.TotalDays / 356.0)).ToString() + " years";
            lnkFaction.Text     = human.faction.name;
            if (human.settlement != null)
            {
                lnkSettlement.Visible = lblSettlement.Visible = true;
                lnkSettlement.Text    = human.settlement.name;
            }
            else
            {
                lnkSettlement.Visible = lblSettlement.Visible = false;
            }

            if (human.parentFamily != null)
            {
                lnkFather.Enabled = lnkMother.Enabled = true;
                lnkFather.Text    = human.parentFamily.husband.name;
                lnkMother.Text    = human.parentFamily.wife.name;
            }
            else
            {
                lnkFather.Enabled = lnkMother.Enabled = false;
                lnkFather.Text    = "None";
                lnkMother.Text    = "None";
            }

            if (human.family != null)
            {
                pnlFamilyInfo.Visible = true;
                if (human.isMale)
                {
                    lblSpouse.Text = "Wife : ";
                    lnkSpouse.Text = human.family.wife.name;
                }
                else
                {
                    lblSpouse.Text = "Husband : ";
                    lnkSpouse.Text = human.family.husband.name;
                }

                txtStartDate.Text         = human.family.startDate.ToLongDateString();
                chkActiveMarriage.Checked = !human.family.isDivorced;
                if (human.family.isDivorced)
                {
                    txtEndDate.Text = human.family.endDate.Value.ToLongDateString();
                }

                if (human.family.childs.Count > 0)
                {
                    grbChilds.Visible = true;

                    int rowIndex = -1;
                    int colIndex = -1;
                    if (gridChilds.CurrentCell != null)
                    {
                        rowIndex = gridChilds.CurrentCell.RowIndex;
                        colIndex = gridChilds.CurrentCell.ColumnIndex;
                    }

                    gridChilds.Rows.Clear();

                    List <Human> childs = human.family.childs.ToList();
                    int          index  = 0;
                    foreach (Human h in childs)
                    {
                        int             years  = (int)Math.Round(h.age.TotalDays / 356.0);
                        int             maxAge = (int)Math.Round(h.maxAge.TotalDays / 356.0);
                        DataGridViewRow row    = (DataGridViewRow)gridChilds.Rows[0].Clone();
                        row.SetValues(index++, h.name, h.dateOfBirth.ToShortDateString(), years.ToString());
                        row.Tag = h;
                        gridChilds.Rows.Add(row);
                    }
                    if (rowIndex != -1 && colIndex != -1)
                    {
                        gridChilds.CurrentCell = gridChilds.Rows[rowIndex].Cells[colIndex];
                    }
                }
                else
                {
                    grbChilds.Visible = false;
                }
            }
            else
            {
                pnlFamilyInfo.Visible = false;
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 以Execl文件格式导入配件信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExcelImport_Click(object sender, EventArgs e)
        {
            try
            {
                Dictionary <string, string> PartFieldDic = new Dictionary <string, string>(); //配件列表的列名
                for (int i = 1; i < gvPartsMsgList.Columns.Count; i++)
                {                                                                             //添加配件列字段名和标题文本
                    PartFieldDic.Add(gvPartsMsgList.Columns[i].Name.ToString(), gvPartsMsgList.Columns[i].HeaderText.ToString());
                }
                //弹出导入Excel对话框
                FrmExcelImport frmExcel = new FrmExcelImport(PartFieldDic, ImportTitle);
                DialogResult   DgResult = frmExcel.ShowDialog();
                if (DgResult == DialogResult.OK)
                {
                    string PNumExcelField = string.Empty;
                    string PNamExcelField = string.Empty;
                    string PSpcExcelField = string.Empty;
                    string PDrwExcelField = string.Empty;
                    string PUntExcelField = string.Empty;
                    string PBrdExcelField = string.Empty;
                    string PCfcExcelField = string.Empty;
                    string PBrcExcelField = string.Empty;
                    string PCntExcelField = string.Empty;
                    string PClpExcelField = string.Empty;
                    string PCmyExcelField = string.Empty;
                    string PRmkExcelField = string.Empty;
                    //获取与单据列名匹配的Excel表格列名
                    foreach (DictionaryEntry DicEty in frmExcel.MatchFieldHTable)
                    {
                        string BillField  = DicEty.Key.ToString();   //获取匹配单据的列名
                        string ExcelField = DicEty.Value.ToString(); //获取匹配Excel表格的列名

                        switch (BillField)
                        {
                        case PNum:
                            PNumExcelField = ExcelField;
                            break;

                        case PNam:
                            PNamExcelField = ExcelField;
                            break;

                        case PSpc:
                            PSpcExcelField = ExcelField;
                            break;

                        case PDrw:
                            PDrwExcelField = ExcelField;
                            break;

                        case PUnt:
                            PUntExcelField = ExcelField;
                            break;

                        case PBrd:
                            PBrdExcelField = ExcelField;
                            break;

                        case PCfc:
                            PCfcExcelField = ExcelField;
                            break;

                        case PBrc:
                            PBrcExcelField = ExcelField;
                            break;

                        case PCnt:
                            PCntExcelField = ExcelField;
                            break;

                        case PUtp:
                            PClpExcelField = ExcelField;
                            break;

                        case PCmy:
                            PCmyExcelField = ExcelField;
                            break;

                        case PRmk:
                            PRmkExcelField = ExcelField;
                            break;
                        }
                    }
                    if (ValidityCellIsnull(frmExcel.ExcelTable))
                    {
                        for (int i = 0; i < frmExcel.ExcelTable.Rows.Count; i++)
                        {
                            DataGridViewRow DgRow = gvPartsMsgList.Rows[gvPartsMsgList.Rows.Add()];//创建新行项

                            DgRow.Cells[PNum].Value = frmExcel.ExcelTable.Rows[i][PNumExcelField].ToString();
                            DgRow.Cells[PNam].Value = frmExcel.ExcelTable.Rows[i][PNamExcelField].ToString();
                            DgRow.Cells[PSpc].Value = frmExcel.ExcelTable.Rows[i][PSpcExcelField].ToString();
                            DgRow.Cells[PDrw].Value = frmExcel.ExcelTable.Rows[i][PDrwExcelField].ToString();
                            DgRow.Cells[PUnt].Value = frmExcel.ExcelTable.Rows[i][PUntExcelField].ToString();
                            DgRow.Cells[PBrd].Value = frmExcel.ExcelTable.Rows[i][PBrdExcelField].ToString();
                            DgRow.Cells[PCfc].Value = frmExcel.ExcelTable.Rows[i][PCfcExcelField].ToString();
                            DgRow.Cells[PBrc].Value = frmExcel.ExcelTable.Rows[i][PBrcExcelField].ToString();
                            DgRow.Cells[PCnt].Value = frmExcel.ExcelTable.Rows[i][PCntExcelField].ToString();
                            DgRow.Cells[PUtp].Value = frmExcel.ExcelTable.Rows[i][PClpExcelField].ToString();
                            DgRow.Cells[PCmy].Value = frmExcel.ExcelTable.Rows[i][PCmyExcelField].ToString();
                            DgRow.Cells[PRmk].Value = frmExcel.ExcelTable.Rows[i][PRmkExcelField].ToString();
                        }
                    }

                    frmExcel.ExcelTable.Clear();//清空所有配件信息
                    MessageBoxEx.Show("导入成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(ex.Message, "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
	// Constructors
	public DataGridViewRowStateChangedEventArgs(DataGridViewRow dataGridViewRow, DataGridViewElementStates stateChanged) {}
	public virtual void Remove(DataGridViewRow dataGridViewRow) {}
Esempio n. 16
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            AddMemberOfCastAndCrewForm addMemberOfCastAndCrew = new AddMemberOfCastAndCrewForm("actor");

            if (dgvActors.SelectedRows.Count > 0)
            {
                try
                {
                    using (MovieDB context = new MovieDB())
                    {
                        DataGridViewRow row   = dgvActors.SelectedRows[0];
                        actor           actor = (actor)row.Tag;
                        addMemberOfCastAndCrew.FirstName  = actor.member_of_cast_and_crew.first_name;
                        addMemberOfCastAndCrew.LastName   = actor.member_of_cast_and_crew.last_name;
                        addMemberOfCastAndCrew.Birthplace = actor.member_of_cast_and_crew.birthplace;
                        addMemberOfCastAndCrew.Born       = actor.member_of_cast_and_crew.born;
                        if (actor.member_of_cast_and_crew.died.HasValue)
                        {
                            addMemberOfCastAndCrew.Dead = true;
                            addMemberOfCastAndCrew.Died = actor.member_of_cast_and_crew.died.Value;
                        }
                        else
                        {
                            addMemberOfCastAndCrew.Dead = false;
                        }
                        addMemberOfCastAndCrew.MemberImage = actor.member_of_cast_and_crew.image;
                        addMemberOfCastAndCrew.Bio         = actor.member_of_cast_and_crew.bio;
                        var directors = (from c in context.directors
                                         where c.id == actor.id &&
                                         c.member_of_cast_and_crew.active == 1
                                         select c).ToList();
                        if (directors.Count > 0)
                        {
                            addMemberOfCastAndCrew.DoubleMember = true;
                        }
                        else
                        {
                            addMemberOfCastAndCrew.DoubleMember = false;
                        }

                        if (DialogResult.OK == addMemberOfCastAndCrew.ShowDialog())
                        {
                            context.actors.Attach(actor);
                            actor.member_of_cast_and_crew.first_name = addMemberOfCastAndCrew.FirstName;
                            actor.member_of_cast_and_crew.last_name  = addMemberOfCastAndCrew.LastName;
                            actor.member_of_cast_and_crew.birthplace = addMemberOfCastAndCrew.Birthplace;
                            actor.member_of_cast_and_crew.born       = addMemberOfCastAndCrew.Born;
                            if (addMemberOfCastAndCrew.Dead)
                            {
                                actor.member_of_cast_and_crew.died = addMemberOfCastAndCrew.Died;
                            }
                            else
                            {
                                actor.member_of_cast_and_crew.died = null;
                            }
                            actor.member_of_cast_and_crew.image = addMemberOfCastAndCrew.MemberImage;
                            actor.member_of_cast_and_crew.bio   = addMemberOfCastAndCrew.Bio;

                            if (addMemberOfCastAndCrew.DoubleMember)
                            {
                                if (directors.Count == 0)
                                {
                                    var director = new director()
                                    {
                                        member_of_cast_and_crew = actor.member_of_cast_and_crew
                                    };
                                    context.directors.Add(director);
                                }
                            }
                            else
                            {
                                if (directors.Count > 0)
                                {
                                    var director = directors[0];
                                    context.directors.Remove(director);
                                }
                            }
                            context.SaveChanges();
                            RefreshTableAndFilters();
                            DirectorsUcl.Instance.RefreshTableAndFilters();
                            MoviesUcl.Instance.RefreshTableAndFilters();
                            MessageBox.Show("Changes successfully saved.", "Success", MessageBoxButtons.OK);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }
            else
            {
                MessageBox.Show("You haven't chosen an actor.", "Warning", MessageBoxButtons.OK);
            }
        }
Esempio n. 17
0
        private void SetearFila(DataGridViewRow r, Categoria Categoria)
        {
            r.Cells[cmnCategoria.Index].Value = Categoria.NombreCategoria;

            r.Tag = Categoria;
        }
Esempio n. 18
0
        private void btnEditItem_Click(object sender, EventArgs e)
        {
            if (this.dgvDetailsList.SelectedRows != null)
            {
                string stkCode = string.Empty, appendix1 = string.Empty, appendix2 = string.Empty, appendix3 = string.Empty;
                this.ItemInfo(ref stkCode, ref appendix1, ref appendix2, ref appendix3);

                DataGridViewRow rows = dgvDetailsList.Rows[dgvDetailsList.CurrentCell.RowIndex];

                rows.Cells[2].Value = rows.Cells[2].Value.ToString() != "NEW" ? "EDIT" : rows.Cells[2].Value; //// Status
                rows.Cells[3].Value = stkCode;                                                                //// Stock Code
                rows.Cells[4].Value = appendix1;                                                              //// Appendix1
                rows.Cells[5].Value = appendix2;                                                              //// Appendix2
                rows.Cells[6].Value = appendix3;                                                              //// Appendix3
                rows.Cells[7].Value = this.txtCost.Text;                                                      //// Unit Cost
                rows.Cells[8].Value = this.productId.ToString();                                              //// ProductId

                for (int i = 9; i <= 18; i++)
                {
                    if (this.dgvDetailsList.Columns[i].Visible)
                    {
                        if (this.cboLocation.SelectedItem.ToString() == this.dgvDetailsList.Columns[i].HeaderText)
                        {
                            rows.Cells[i].Value = (this.txtQty.Text.Length == 0 ? "0" : this.txtQty.Text); //// Qty1
                        }
                        else if (this.cboLocation.SelectedItem.ToString() == "All")
                        {
                            rows.Cells[i].Value = (this.txtQty.Text.Length == 0 ? "0" : this.txtQty.Text); //// Qty1
                        }
                        else
                        {
                            rows.Cells[i].Value = "0"; //// Qty1
                        }
                    }
                    else
                    {
                        rows.Cells[i].Value = "0"; //// Qty1
                    }
                }

                int totalQty = 0;
                for (int i = 9; i <= 18; i++)
                {
                    if (this.dgvDetailsList.Columns[i].Visible)
                    {
                        if (this.cboLocation.SelectedItem.ToString() == this.dgvDetailsList.Columns[i].HeaderText)
                        {
                            totalQty += Convert.ToInt32(rows.Cells[i].Value.ToString());
                        }
                        else if (this.cboLocation.SelectedItem.ToString() == "All")
                        {
                            totalQty += Convert.ToInt32(rows.Cells[i].Value.ToString());
                        }
                    }
                }

                rows.Cells[19].Value = totalQty.ToString("n0");                         //// Total Qty
                //string totalCost = (totalQty * Convert.ToDecimal(this.txtCost.Text)).ToString();
                rows.Cells[20].Value = totalQty * Convert.ToDecimal(this.txtCost.Text); //// Total Cost
                rows.Cells[21].Value = (this.txtQty.Text.Length == 0 ? "0" : this.txtQty.Text);

                //this.dgvDetailsList.Rows[dgvDetailsList.CurrentCell.RowIndex].SetValues(rows);

                this.CalcTotal();
            }
        }
Esempio n. 19
0
        void JLMXB_DataBind(DataGridViewRow dgr)
        {
            string str_zhxm = dgr.Cells["zhxm"].Value.ToString().Trim();
            string str_xh   = dgr.Cells["xh"].Value.ToString().Trim();
            string str_xmlx = dgr.Cells["xmlx"].Value.ToString().Trim();       //0检验科 1医生检查 2功能检查
            string str_lxbh = dgr.Cells["lxbh"].Value.ToString().Trim();       //类型编号,科室ID

            dgv_tjjlmxb.DataSource = tjjgbiz.Get_TJ_TJJLMXB(str_xh, str_zhxm); //---------------------
            dgv_tjjlmxb.Tag        = str_xmlx;                                 //Tag保存项目类型值-----------------------------------------------------------------------------------
            if (str_xmlx == "0")
            {
                dgv_tjjlmxb.Columns["tjjlmxb_jg"].Width     = 80;
                dgv_tjjlmxb.Columns["tjjlmxb_dw"].Visible   = true;
                dgv_tjjlmxb.Columns["tjjlmxb_ckxx"].Visible = true;
                dgv_tjjlmxb.Columns["tjjlmxb_cksx"].Visible = true;
            }
            if (str_xmlx == "1")
            {
                dgv_tjjlmxb.Columns["tjjlmxb_jg"].Width     = 200;
                dgv_tjjlmxb.Columns["tjjlmxb_dw"].Visible   = true;
                dgv_tjjlmxb.Columns["tjjlmxb_ckxx"].Visible = false;
                dgv_tjjlmxb.Columns["tjjlmxb_cksx"].Visible = false;
            }
            if (str_xmlx == "2")
            {
                dgv_tjjlmxb.Columns["tjjlmxb_jg"].Width     = 300;
                dgv_tjjlmxb.Columns["tjjlmxb_dw"].Visible   = false;
                dgv_tjjlmxb.Columns["tjjlmxb_ckxx"].Visible = false;
                dgv_tjjlmxb.Columns["tjjlmxb_cksx"].Visible = false;
            }

            //1初始化参考值 2获取该项疾病记录 3异常情况,结果以红色字体显示
            foreach (DataGridViewRow dgrow in dgv_tjjlmxb.Rows)
            {
                string str_tjlx = dgrow.Cells["tjjlmxb_tjlx"].Value.ToString().Trim();
                string str_tjxm = dgrow.Cells["tjjlmxb_tjxm"].Value.ToString().Trim();
                //检验科获取参考值
                if (str_xmlx == "0")
                {
                    int nl = 0;
                    try
                    {
                        nl = Convert.ToInt32(str_nl);
                    }
                    catch
                    {
                    }

                    DataTable dt_gz = new tjdj.tjdjBiz().Get_TJ_TJDJB(str_tjbh, str_tjcs);
                    string    gz    = "";
                    if (dt_gz.Rows.Count > 0)
                    {
                        gz = dt_gz.Rows[0]["gz"].ToString().Trim();
                    }

                    DataTable dtCkz = tjjgbiz.Get_pro_get_ckz(str_tjlx, str_tjxm, str_xb, nl, gz);
                    if (dtCkz.Rows.Count <= 0)
                    {
                        continue;
                    }
                    string str_ckz = dtCkz.Rows[0]["ckz"].ToString().Trim();
                    if (str_ckz == "")
                    {
                        continue;               //获取值为空跳过,设置有问题
                    }
                    dgrow.Cells["tjjlmxb_ckxx"].Value = str_ckz.Split('—')[0];
                    dgrow.Cells["tjjlmxb_cksx"].Value = str_ckz.Split('—')[1];
                    dgrow.Cells["tjjlmxb_ckz"].Value  = str_ckz;
                    dgrow.Cells["spy"].Value          = dtCkz.Rows[0]["spy"].ToString().Trim();
                    dgrow.Cells["xpy"].Value          = dtCkz.Rows[0]["xpy"].ToString().Trim();
                }
                //异常情况,结果以红色字体显示
                string str_sfyx = dgrow.Cells["tjjlmxb_sfyx"].Value.ToString().Trim();
                if (str_sfyx == "1")
                {
                    dgrow.Cells["tjjlmxb_jg"].Style.ForeColor = Color.Red;
                }
            }

            rtb_xj.Text = "";
            DataTable dt = tjjgbiz.Get_TJ_TJJLB(str_tjbh, str_tjcs, str_xh, str_zhxm);

            try
            {
                dtp_jcrq.Value         = Convert.ToDateTime(dt.Rows[0]["jcrq"]);
                cmb_czy.SelectedValue  = dt.Rows[0]["czy"].ToString().Trim();
                cmb_jcys.SelectedValue = dt.Rows[0]["jcys"].ToString().Trim();
                rtb_xj.Text            = dt.Rows[0]["xj"].ToString().Trim();
            }
            catch { }
        }
Esempio n. 20
0
        private void LoadData()
        {
            DBGrid.Columns.Clear();
            ArrayList arrHeader = new ArrayList();
            ArrayList arrTitle  = new ArrayList();

            arrHeader.Add(clsTranslate.TranslateString("GroupId"));
            arrHeader.Add(clsTranslate.TranslateString("TaskCode"));
            arrHeader.Add(clsTranslate.TranslateString("TaskName"));
            arrTitle.Add(clsTranslate.TranslateString("GroupId"));
            arrTitle.Add(clsTranslate.TranslateString("TaskCode"));
            arrTitle.Add(clsTranslate.TranslateString("TaskName"));
            dalUserList blluser = new dalUserList();
            BindingCollection <modUserList> listuser = blluser.GetIList(true, out Util.emsg);

            if (listuser != null && listuser.Count > 0)
            {
                foreach (modUserList mod in listuser)
                {
                    arrHeader.Add(mod.UserId);
                    arrTitle.Add(mod.UserName);
                }
            }
            for (int i = 0; i < arrHeader.Count; i++)
            {
                //if (i <= 1)
                //{
                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
                col.HeaderText       = arrTitle[i].ToString();
                col.DataPropertyName = arrHeader[i].ToString();
                col.Name             = arrHeader[i].ToString();
                if (i == 1)
                {
                    col.Visible = false;
                }
                else if (i == 0 || i == 2)
                {
                    col.Width = 120;
                }
                else
                {
                    col.Width = 30;
                }
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                DBGrid.Columns.Add(col);
                col.Dispose();
                //}
                //else
                //{
                //    DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn();
                //    col.HeaderText = arrTitle[i].ToString();
                //    col.DataPropertyName = arrHeader[i].ToString();
                //    col.Width = 70;
                //    DBGrid.Columns.Add(col);
                //    col.Dispose();
                //}
            }

            DataGridViewRow row;
            dalTaskList     bll = new dalTaskList();
            BindingCollection <modTaskList> list = bll.GetIList(string.Empty, false, false, out Util.emsg);

            if (list != null && list.Count > 0)
            {
                foreach (modTaskList mod in list)
                {
                    row = new DataGridViewRow();
                    row.CreateCells(DBGrid);
                    row.Cells[0].Value = clsTranslate.TranslateString(mod.GroupId);
                    row.Cells[1].Value = mod.TaskCode;
                    row.Cells[2].Value = clsTranslate.TranslateString(mod.TaskName);
                    DBGrid.Rows.Add(row);
                    row.Dispose();
                }
            }
            for (int iCol = 3; iCol < DBGrid.ColumnCount; iCol++)
            {
                dalTaskGrant blltg = new dalTaskGrant();
                BindingCollection <modTaskGrant> listtg = blltg.GetUserGrantData(false, false, DBGrid.Columns[iCol].Name, string.Empty, string.Empty, out Util.emsg);
                if (listtg != null && listtg.Count > 0)
                {
                    foreach (modTaskGrant mod in listtg)
                    {
                        for (int iRow = 0; iRow < DBGrid.RowCount; iRow++)
                        {
                            if (mod.TaskCode.CompareTo(DBGrid.Rows[iRow].Cells[1].Value.ToString()) == 0)
                            {
                                DBGrid.Rows[iRow].Cells[iCol].Value = "√";
                                break;
                            }
                        }
                    }
                }
            }
            DBGrid.Columns[2].Frozen = true;
            DBGrid.AlternatingRowsDefaultCellStyle.BackColor = Color.Empty;
            DBGrid.Columns[0].DefaultCellStyle.BackColor     = frmOptions.ALTERNATING_BACKCOLOR;
            DBGrid.Columns[1].DefaultCellStyle.BackColor     = frmOptions.ALTERNATING_BACKCOLOR;
            DBGrid.Columns[2].DefaultCellStyle.BackColor     = frmOptions.ALTERNATING_BACKCOLOR;
            DBGrid.MergeColumnNames.Add(arrHeader[0].ToString());
            DBGrid.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;
        }
Esempio n. 21
0
        private void extButtonExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View", "All" }, disablestartendtime: true);

            if (frm.ShowDialog(this.FindForm()) == DialogResult.OK)
            {
                BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                grd.SetCSVDelimiter(frm.Comma);

                grd.GetLineHeader += delegate(int c)
                {
                    if (c == 0)
                    {
                        return new string[] { "Time", "System", "Body", "Note", "Tags" }
                    }
                    ;
                    else
                    {
                        return(null);
                    }
                };

                if (frm.SelectedIndex == 1)
                {
                    List <CaptainsLogClass> logs = GlobalCaptainsLogList.Instance.LogEntries;
                    int i = 0;

                    grd.GetLine += delegate(int r)
                    {
                        while (i < logs.Count)
                        {
                            CaptainsLogClass ent = logs[i++];
                            if (ent.Commander == EDCommander.CurrentCmdrID)
                            {
                                return(new object[] { EDDConfig.Instance.ConvertTimeToSelectedFromUTC(ent.TimeUTC),
                                                      ent.SystemName, ent.BodyName, ent.Note, ent.Tags });
                            }
                        }

                        return(null);
                    };
                }
                else
                {
                    grd.GetLine += delegate(int r)
                    {
                        if (r < dataGridView.RowCount)
                        {
                            DataGridViewRow  rw  = dataGridView.Rows[r];
                            CaptainsLogClass ent = rw.Tag as CaptainsLogClass;
                            return(new Object[] { rw.Cells[0].Value, rw.Cells[1].Value, rw.Cells[2].Value, rw.Cells[3].Value, ent.Tags });
                        }

                        return(null);
                    };
                }

                grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
            }
        }
Esempio n. 22
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                int rowindex = dataGridView1.CurrentRow.Index;
                if (rowindex >= 0)
                {
                    DataGridViewRow row = dataGridView1.Rows[rowindex];

                    dateTimePicker1.Value = Convert.ToDateTime(row.Cells["建立日期"].Value.ToString());

                    textBox3.Text  = row.Cells["工號"].Value.ToString();
                    textBox4.Text  = row.Cells["保管人"].Value.ToString();
                    comboBox2.Text = row.Cells["部門"].Value.ToString();
                    textBox5.Text  = row.Cells["單位"].Value.ToString();
                    comboBox3.Text = row.Cells["分類"].Value.ToString();
                    textBox6.Text  = row.Cells["分類名"].Value.ToString();
                    textBox7.Text  = row.Cells["流水號"].Value.ToString();
                    textBox8.Text  = row.Cells["保管品名"].Value.ToString();
                    textBox9.Text  = row.Cells["廠牌"].Value.ToString();
                    textBox10.Text = row.Cells["規格"].Value.ToString();
                    textBox11.Text = row.Cells["原價"].Value.ToString();
                    textBox12.Text = row.Cells["數量"].Value.ToString();
                    textBox13.Text = row.Cells["發放人"].Value.ToString();
                    textBox14.Text = row.Cells["備註"].Value.ToString();

                    NOID    = row.Cells["流水號"].Value.ToString();
                    OWNNAME = row.Cells["保管品名"].Value.ToString();
                    BRAND   = row.Cells["廠牌"].Value.ToString();
                    SPEC    = row.Cells["規格"].Value.ToString();
                    ID      = row.Cells["工號"].Value.ToString();
                    NAME    = row.Cells["保管人"].Value.ToString();
                    DEP     = row.Cells["部門"].Value.ToString();
                    DEPNAME = row.Cells["單位"].Value.ToString();
                }
                else
                {
                    textBox3.Text  = null;
                    textBox4.Text  = null;
                    textBox5.Text  = null;
                    textBox6.Text  = null;
                    textBox7.Text  = null;
                    textBox8.Text  = null;
                    textBox9.Text  = null;
                    textBox10.Text = null;
                    textBox11.Text = null;
                    textBox12.Text = null;
                    textBox13.Text = null;
                    textBox14.Text = null;

                    NOID    = null;
                    OWNNAME = null;
                    BRAND   = null;
                    SPEC    = null;
                    ID      = null;
                    NAME    = null;
                    DEP     = null;
                    DEPNAME = null;
                }
            }
        }
		public DataGridViewRowStateChangedEventArgs (DataGridViewRow dataGridViewRow, DataGridViewElementStates stateChanged) {
			this.dataGridViewRow = dataGridViewRow;
			this.stateChanged = stateChanged;
		}
Esempio n. 24
0
        public ClubPointForm()
        {
            InitializeComponent();
            DateSetting.Save();

            BGW = new BackgroundWorker();
            BGW.RunWorkerCompleted += BGW_RunWorkerCompleted;
            BGW.DoWork             += BGW_DoWork;

            // 如果沒日期設定資料
            // DateTimeInput 預設為當天
            // CheckBox 預設為勾選
            if (string.IsNullOrEmpty(DateSetting["DateSetting"]))
            {
                dateTimeInput1.Value = DateTime.Today;
                dateTimeInput2.Value = DateTime.Today.AddDays(6);

                GetDateTime_Click(null, null);
                // 紀錄日期清單資料
                string node = "";
                foreach (DataGridViewRow dr in dataGridViewX1.Rows)
                {
                    node += "<Dgv date = \"" + dr.Cells["Column1"].Value + "\" week = \"" + dr.Cells["column2"].Value + "\"></Dgv>";
                }

                DateSetting["DateSetting"] = string.Format(@"<DateSetting><Weeks><Week name = ""Monday"" checked = ""true""/><Week name = ""Tuesday"" checked = ""true"" /><Week name = ""Wednesday"" checked = ""true"" /><Week name = ""Thursday"" checked = ""true"" /><Week name = ""Friday"" checked = ""true"" /><Week name = ""Saturday"" checked = ""true"" /><Week name = ""Sunday"" checked = ""true"" /></Weeks><StarDate Date = ""{0}"" ></StarDate><EndDate Date = ""{1}"" ></EndDate><DataGridView>{2}</DataGridView></DateSetting>"
                                                           , DateTime.Today, DateTime.Today.AddDays(6), node);
                DateSetting.Save();
                return;
            }
            // 如果有日期設定資料
            if (DateSetting.Contains("DateSetting") && !string.IsNullOrEmpty(DateSetting["DateSetting"]))
            {
                XmlElement _DateSetting = K12.Data.XmlHelper.LoadXml(DateSetting["DateSetting"]);
                XDocument  _dateSetting = XDocument.Parse(_DateSetting.OuterXml);
                // Init DateTimeInput
                DateTime StarDate = DateTime.Parse(_dateSetting.Element("DateSetting").Element("StarDate").Attribute("Date").Value);
                DateTime EndDate  = DateTime.Parse(_dateSetting.Element("DateSetting").Element("EndDate").Attribute("Date").Value);
                dateTimeInput1.Value = StarDate;
                dateTimeInput2.Value = EndDate;
                // Init CheckBox
                List <XElement> Weeks = _dateSetting.Element("DateSetting").Element("Weeks").Elements("Week").ToList();
                foreach (XElement week in Weeks)
                {
                    if (week.Attribute("name").Value == "Monday")
                    {
                        cbDay1.Checked = bool.Parse(week.Attribute("checked").Value);
                    }
                    if (week.Attribute("name").Value == "Tuesday")
                    {
                        cbDay2.Checked = bool.Parse(week.Attribute("checked").Value);
                    }
                    if (week.Attribute("name").Value == "Wednesday")
                    {
                        cbDay3.Checked = bool.Parse(week.Attribute("checked").Value);
                    }
                    if (week.Attribute("name").Value == "Thursday")
                    {
                        cbDay4.Checked = bool.Parse(week.Attribute("checked").Value);
                    }
                    if (week.Attribute("name").Value == "Friday")
                    {
                        cbDay5.Checked = bool.Parse(week.Attribute("checked").Value);
                    }
                    if (week.Attribute("name").Value == "Saturday")
                    {
                        cbDay6.Checked = bool.Parse(week.Attribute("checked").Value);
                    }
                    if (week.Attribute("name").Value == "Sunday")
                    {
                        cbDay7.Checked = bool.Parse(week.Attribute("checked").Value);
                    }
                }
                // Init DataGridView
                List <XElement> Dgv = _dateSetting.Element("DateSetting").Element("DataGridView").Elements("Dgv").ToList();
                foreach (XElement dgvr in Dgv)
                {
                    DataGridViewRow dr = new DataGridViewRow();
                    dr.CreateCells(dataGridViewX1);

                    dr.Cells[0].Value = dgvr.Attribute("date").Value;
                    dr.Cells[1].Value = dgvr.Attribute("week").Value;

                    dataGridViewX1.Rows.Add(dr);
                }
            }

            //dateTimeInput1.Value = DateTime.Today;
            //dateTimeInput2.Value = DateTime.Today.AddDays(7);
        }
	public virtual int Add(DataGridViewRow dataGridViewRow) {}
Esempio n. 26
0
        private void GetDateTime_Click(object sender, EventArgs e)
        {
            //建立日期清單
            TimeSpan ts = dateTimeInput2.Value - dateTimeInput1.Value;

            List <DateTime> TList = new List <DateTime>();

            foreach (DataGridViewRow row in dataGridViewX1.Rows)
            {
                DateTime dt;
                DateTime.TryParse("" + row.Cells[0].Value, out dt);
                TList.Add(dt);
            }

            List <DayOfWeek> WeekList = new List <DayOfWeek>();

            if (cbDay1.Checked)
            {
                WeekList.Add(DayOfWeek.Monday);
            }
            if (cbDay2.Checked)
            {
                WeekList.Add(DayOfWeek.Tuesday);
            }
            if (cbDay3.Checked)
            {
                WeekList.Add(DayOfWeek.Wednesday);
            }
            if (cbDay4.Checked)
            {
                WeekList.Add(DayOfWeek.Thursday);
            }
            if (cbDay5.Checked)
            {
                WeekList.Add(DayOfWeek.Friday);
            }
            if (cbDay6.Checked)
            {
                WeekList.Add(DayOfWeek.Saturday);
            }
            if (cbDay7.Checked)
            {
                WeekList.Add(DayOfWeek.Sunday);
            }
            for (int x = 0; x <= ts.Days; x++)
            {
                DateTime dt = dateTimeInput1.Value.AddDays(x);

                if (WeekList.Contains(dt.DayOfWeek))
                {
                    if (!TList.Contains(dt))
                    {
                        TList.Add(dt);
                    }
                }
            }

            TList.Sort();
            //資料填入
            dataGridViewX1.Rows.Clear();
            foreach (DateTime dt in TList)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dataGridViewX1);
                row.Cells[0].Value = dt.ToShortDateString();
                row.Cells[1].Value = tool.CheckWeek(dt.DayOfWeek.ToString());
                dataGridViewX1.Rows.Add(row);
            }
        }
	public virtual bool Contains(DataGridViewRow dataGridViewRow) {}
Esempio n. 28
0
        private void MapFiles(object sender, EventArgs e)
        {
            if (_sourceFileAnalyzer == null || _targetFileAnalyzer == null)
            {
                return;
            }

            var sourceFile = Path.GetFileNameWithoutExtension(_sourceFile);
            var targetFile = Path.GetFileNameWithoutExtension(_targetFile);

            if (sourceFile != targetFile)
            {
                return;
            }

            targetGridView.Rows.Clear();

            var mappingResolver = new MappingResolver(sourceFile, _sourceFileAnalyzer, _targetFileAnalyzer);

            foreach (var mapping in mappingResolver)
            {
                var dataRow  = new DataGridViewRow();
                var dataType = (mapping.Key as PropertyInfo)?.PropertyType;
                if (dataType == null)
                {
                    throw new InvalidOperationException("unreachable");
                }

                var arraySize = 0;
                if (dataType.IsArray)
                {
                    dataType  = dataType.GetElementType();
                    arraySize = mapping.Key.GetCustomAttribute <CardinalityAttribute>().SizeConst;
                }

                var isIndex = mapping.Key.IsDefined(typeof(IndexAttribute), false);

                if (mapping.Value.From == null)
                {
                    dataRow.Cells.Add(new DataGridViewTextBoxCell {
                        Value = mapping.Key.Name
                    });
                    dataRow.Cells.Add(new DataGridViewTextBoxCell {
                        Value = dataType.ToAlias()
                    });
                    dataRow.Cells.Add(new DataGridViewTextBoxCell {
                        Value = arraySize == 0 ? "" : arraySize.ToString()
                    });
                    dataRow.Cells.Add(new DataGridViewCheckBoxCell {
                        Value = isIndex
                    });
                }
                else
                {
                    dataRow.Cells.Add(new DataGridViewTextBoxCell {
                        Value = mapping.Value.From.Name
                    });
                    dataRow.Cells.Add(new DataGridViewTextBoxCell {
                        Value = dataType.ToAlias()
                    });
                    dataRow.Cells.Add(new DataGridViewTextBoxCell {
                        Value = arraySize == 0 ? "" : arraySize.ToString()
                    });
                    dataRow.Cells.Add(new DataGridViewCheckBoxCell {
                        Value = isIndex
                    });
                }
                targetGridView.Rows.Add(dataRow);
                _targetFileAnalyzer.RecordType = mappingResolver.Type;
            }
            Console.WriteLine("Mapped");
        }
	public int IndexOf(DataGridViewRow dataGridViewRow) {}
	public bool Contains(DataGridViewRow dataGridViewRow) {}
	public virtual void InsertRange(int rowIndex, DataGridViewRow[] dataGridViewRows) {}
	public void Insert(int index, DataGridViewRow dataGridViewRow) {}
Esempio n. 33
0
 private void AgregarFila(DataGridViewRow r)
 {
     dgvDatos.Rows.Add(r);
 }
Esempio n. 34
0
        private void printSummary_PrintPage(object sender, PrintPageEventArgs e)
        {
            try
            {
                //Set the left margin
                int iLeftMargin = e.MarginBounds.Left;
                //Set the top margin
                int iTopMargin = e.MarginBounds.Top;
                //Whether more pages have to print or not
                bool bMorePagesToPrint = false;
                int  iTmpWidth         = 0;

                //For the first page to print set the cell width and header height
                if (bFirstPage)
                {
                    foreach (DataGridViewColumn GridCol in dgv_Summary.Columns)
                    {
                        iTmpWidth = (int)(Math.Floor(GridCol.Width /
                                                     (double)iTotalWidth * iTotalWidth *
                                                     ((double)e.MarginBounds.Width / iTotalWidth)));

                        iHeaderHeight = (int)(e.Graphics.MeasureString(GridCol.HeaderText,
                                                                       GridCol.InheritedStyle.Font, iTmpWidth).Height) + 11;

                        // Save width and height of headers
                        arrColumnLefts.Add(iLeftMargin);
                        arrColumnWidths.Add(iTmpWidth);
                        iLeftMargin += iTmpWidth;
                    }
                }
                //Loop till all the grid rows not get printed
                while (iRow <= dgv_Summary.Rows.Count - 1)
                {
                    DataGridViewRow GridRow = dgv_Summary.Rows[iRow];
                    //Set the cell height
                    iCellHeight = GridRow.Height + 5;
                    int iCount = 0;
                    //Check whether the current page settings allows more rows to print
                    if (iTopMargin + iCellHeight >= e.MarginBounds.Height + e.MarginBounds.Top)
                    {
                        bNewPage          = true;
                        bFirstPage        = false;
                        bMorePagesToPrint = true;
                        break;
                    }
                    else
                    {
                        if (bNewPage)
                        {
                            //Draw Header
                            e.Graphics.DrawString("Summary",
                                                  new Font(dgv_Summary.Font, FontStyle.Bold),
                                                  Brushes.Black, e.MarginBounds.Left,
                                                  e.MarginBounds.Top - e.Graphics.MeasureString("Summary",
                                                                                                new Font(dgv_Summary.Font, FontStyle.Bold),
                                                                                                e.MarginBounds.Width).Height - 13);

                            String strDate = DateTime.Now.ToLongDateString() + " " +
                                             DateTime.Now.ToShortTimeString();
                            //Draw Date
                            e.Graphics.DrawString(strDate,
                                                  new Font(dgv_Summary.Font, FontStyle.Bold), Brushes.Black,
                                                  e.MarginBounds.Left +
                                                  (e.MarginBounds.Width - e.Graphics.MeasureString(strDate,
                                                                                                   new Font(dgv_Summary.Font, FontStyle.Bold),
                                                                                                   e.MarginBounds.Width).Width),
                                                  e.MarginBounds.Top - e.Graphics.MeasureString("Summary",
                                                                                                new Font(new Font(dgv_Summary.Font, FontStyle.Bold),
                                                                                                         FontStyle.Bold), e.MarginBounds.Width).Height - 13);

                            //Draw Columns
                            iTopMargin = e.MarginBounds.Top;
                            foreach (DataGridViewColumn GridCol in dgv_Summary.Columns)
                            {
                                e.Graphics.FillRectangle(new SolidBrush(Color.LightGray),
                                                         new Rectangle((int)arrColumnLefts[iCount], iTopMargin,
                                                                       (int)arrColumnWidths[iCount], iHeaderHeight));

                                e.Graphics.DrawRectangle(Pens.Black,
                                                         new Rectangle((int)arrColumnLefts[iCount], iTopMargin,
                                                                       (int)arrColumnWidths[iCount], iHeaderHeight));

                                e.Graphics.DrawString(GridCol.HeaderText,
                                                      GridCol.InheritedStyle.Font,
                                                      new SolidBrush(GridCol.InheritedStyle.ForeColor),
                                                      new RectangleF((int)arrColumnLefts[iCount], iTopMargin,
                                                                     (int)arrColumnWidths[iCount], iHeaderHeight), strFormat);
                                iCount++;
                            }
                            bNewPage    = false;
                            iTopMargin += iHeaderHeight;
                        }
                        iCount = 0;
                        //Draw Columns Contents
                        foreach (DataGridViewCell Cel in GridRow.Cells)
                        {
                            if (Cel.Value != null)
                            {
                                e.Graphics.DrawString(Cel.Value.ToString(),
                                                      Cel.InheritedStyle.Font,
                                                      new SolidBrush(Cel.InheritedStyle.ForeColor),
                                                      new RectangleF((int)arrColumnLefts[iCount],
                                                                     (float)iTopMargin,
                                                                     (int)arrColumnWidths[iCount], (float)iCellHeight),
                                                      strFormat);
                            }
                            //Drawing Cells Borders
                            e.Graphics.DrawRectangle(Pens.Black,
                                                     new Rectangle((int)arrColumnLefts[iCount], iTopMargin,
                                                                   (int)arrColumnWidths[iCount], iCellHeight));
                            iCount++;
                        }
                    }
                    iRow++;
                    iTopMargin += iCellHeight;
                }
                //If more lines exist, print another page.
                if (bMorePagesToPrint)
                {
                    e.HasMorePages = true;
                }
                else
                {
                    e.HasMorePages = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{Utilities.ERRORMESSAGE} \n Error details: {ex.Message}", "Superior Investment!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 35
0
        private string CaluculateDVH(DataGridViewRow row)
        {
            // Get MU
            if (label_mu.Text == "")
            {
                int MU = 0;
                if (!isPlanSum)
                {
                    var beams = ((PlanSetup)planSetup).Beams;
                    foreach (var beam in beams)
                    {
                        if (!beam.IsSetupField)
                        {
                            MU += (int)Math.Round(beam.Meterset.Value * 10);
                        }
                    }
                    label_mu.Text = (1.0 * MU / 10).ToString("F1");
                }
                else
                {
                    foreach (var plan in ((PlanSum)planSetup).PlanSetups)
                    {
                        foreach (var beam in plan.Beams)
                        {
                            if (!beam.IsSetupField)
                            {
                                MU += (int)Math.Round(beam.Meterset.Value * 10);
                            }
                        }
                    }
                    label_mu.Text = (1.0 * MU / 10).ToString("F1");
                }
            }

            DataGridViewCellCollection row_cells = row.Cells;

            string struct_name      = Convert.ToString(row_cells[Column_structure.Index].Value);
            string dv               = Convert.ToString(row_cells[Column_dv.Index].Value);
            string dv_value         = Convert.ToString(row_cells[Column_dvvalue.Index].Value);
            string dv_unit          = Convert.ToString(row_cells[Column_dvunit.Index].Value);
            string unit             = Convert.ToString(row_cells[Column_unit.Index].Value);
            string result           = Convert.ToString(row_cells[Column_result.Index].Value);
            string sign             = Convert.ToString(row_cells[Column_sign.Index].Value);
            string critria          = Convert.ToString(row_cells[Column_criteria.Index].Value);
            string tol              = Convert.ToString(row_cells[Column_tol.Index].Value);
            string value            = "";
            bool   isUnitDetermined = false;
            string doseUnit         = "";

            string empty = "";

            if (result != "")
            {
                return(result);
            }
            else if (struct_name == "" || dv == "" || unit == "")
            {
                return(empty);
            }
            else
            {
                DoseValuePresentation doseAbs = DoseValuePresentation.Absolute;
                foreach (Structure s in ss.Structures)
                {
                    if (s.Id == struct_name)
                    {
                        var volume = s.Volume;

                        if (!isUnitDetermined)
                        {
                            DoseValue doseValue = planSetup.GetDVHCumulativeData(s, doseAbs, 0, 0.1).MaxDose;
                            doseUnit         = doseValue.UnitAsString;
                            isUnitDetermined = true;
                        }

                        if (dv == "Dmax")
                        {
                            DoseValue doseValue;
                            if (unit == "Gy")
                            {
                                doseValue = planSetup.GetDVHCumulativeData(s, doseAbs, 0, 0.1).MaxDose;
                                value     = doseUnit == "cGy" ? (doseValue.Dose / 100.0).ToString("F2") : doseValue.Dose.ToString("F2");
                            }
                            else
                            {
                                doseValue = planSetup.GetDVHCumulativeData(s, 0, 0, 0.1).MaxDose;
                                value     = doseValue.Dose.ToString("F2");
                            }
                        }
                        else if (dv == "Dmean")
                        {
                            DoseValue doseValue;
                            if (unit == "Gy")
                            {
                                doseValue = planSetup.GetDVHCumulativeData(s, doseAbs, 0, 0.1).MeanDose;
                                value     = doseUnit == "cGy" ? (doseValue.Dose / 100.0).ToString("F2") : doseValue.Dose.ToString("F2");
                            }
                            else
                            {
                                doseValue = planSetup.GetDVHCumulativeData(s, 0, 0, 0.1).MeanDose;
                                value     = doseValue.Dose.ToString("F2");
                            }
                        }
                        else if (dv == "Dmin")
                        {
                            DoseValue doseValue;
                            if (unit == "Gy")
                            {
                                doseValue = planSetup.GetDVHCumulativeData(s, doseAbs, 0, 0.1).MinDose;
                                value     = doseUnit == "cGy" ? (doseValue.Dose / 100.0).ToString("F2") : doseValue.Dose.ToString("F2");
                            }
                            else
                            {
                                doseValue = planSetup.GetDVHCumulativeData(s, 0, 0, 0.1).MinDose;
                                value     = doseValue.Dose.ToString("F2");
                            }
                        }
                        else if (dv == "D" || dv == "DC")
                        {
                            double dx = double.Parse(dv_value);
                            if (dv_unit == "" || dv_value == "")
                            {
                                return(empty);
                            }
                            else if (dv_unit == "%")
                            {
                                if (dx <= 100.0)
                                {
                                    if (unit == "Gy")
                                    {
                                        if (dv == "D")
                                        {
                                            DoseValue doseValue = planSetup.GetDoseAtVolume(s, dx, 0, doseAbs);
                                            value = doseUnit == "cGy" ? (doseValue.Dose / 100.0).ToString("F2") : doseValue.Dose.ToString("F2");
                                        }
                                        else if (dv == "DC")
                                        {
                                            DoseValue doseValue = planSetup.GetDoseAtVolume(s, 100 - dx, 0, doseAbs);
                                            value = doseUnit == "cGy" ? (doseValue.Dose / 100.0).ToString("F2") : doseValue.Dose.ToString("F2");
                                        }
                                    }
                                    else
                                    {
                                        if (dv == "D")
                                        {
                                            DoseValue doseValue = planSetup.GetDoseAtVolume(s, dx, 0, 0);
                                            value = doseValue.Dose.ToString("F2");
                                        }
                                        else if (dv == "DC")
                                        {
                                            DoseValue doseValue = planSetup.GetDoseAtVolume(s, 100 - dx, 0, 0);
                                            value = doseValue.Dose.ToString("F2");
                                        }
                                    }
                                }
                                else
                                {
                                    return(empty);
                                }
                            }
                            else
                            {
                                if (unit == "Gy")
                                {
                                    if (dv == "D")
                                    {
                                        DoseValue doseValue = planSetup.GetDoseAtVolume(s, dx, VolumePresentation.AbsoluteCm3, doseAbs);
                                        value = doseUnit == "cGy" ? (doseValue.Dose / 100.0).ToString("F2") : doseValue.Dose.ToString("F2");
                                    }
                                    else if (dv == "DC")
                                    {
                                        DoseValue doseValue = planSetup.GetDoseAtVolume(s, volume - dx, VolumePresentation.AbsoluteCm3, doseAbs);
                                        value = doseUnit == "cGy" ? (doseValue.Dose / 100.0).ToString("F2") : doseValue.Dose.ToString("F2");
                                    }
                                }
                                else
                                {
                                    if (dv == "D")
                                    {
                                        DoseValue doseValue = planSetup.GetDoseAtVolume(s, dx, VolumePresentation.AbsoluteCm3, 0);
                                        value = doseValue.Dose.ToString("F2");
                                    }
                                    else if (dv == "DC")
                                    {
                                        DoseValue doseValue = planSetup.GetDoseAtVolume(s, volume - dx, VolumePresentation.AbsoluteCm3, 0);
                                        value = doseValue.Dose.ToString("F2");
                                    }
                                }
                            }
                        }
                        else // dv == "V" or "CV"
                        {
                            double vx = double.Parse(dv_value);
                            if (dv_unit == "" || dv_value == "")
                            {
                                return(empty);
                            }
                            else if (dv_unit == "%")
                            {
                                if (unit == "cc")
                                {
                                    DoseValue dose      = new DoseValue(vx, DoseValue.DoseUnit.Percent);
                                    double    doseValue = planSetup.GetVolumeAtDose(s, dose, VolumePresentation.AbsoluteCm3);
                                    if (dv == "V")
                                    {
                                        value = doseValue.ToString("F2");
                                    }
                                    else if (dv == "CV")
                                    {
                                        value = (volume - doseValue).ToString("F2");
                                    }
                                }
                                else
                                {
                                    DoseValue dose      = new DoseValue(vx, DoseValue.DoseUnit.Percent);
                                    double    doseValue = planSetup.GetVolumeAtDose(s, dose, VolumePresentation.Relative);
                                    if (dv == "V")
                                    {
                                        value = doseValue.ToString("F2");
                                    }
                                    else if (dv == "CV")
                                    {
                                        value = (100.0 - doseValue).ToString("F2");
                                    }
                                }
                            }
                            else // dvunit == "Gy"
                            {
                                if (unit == "cc")
                                {
                                    DoseValue dose      = doseUnit == "cGy" ? new DoseValue(vx * 100, DoseValue.DoseUnit.cGy) : new DoseValue(vx, DoseValue.DoseUnit.Gy);
                                    double    doseValue = planSetup.GetVolumeAtDose(s, dose, VolumePresentation.AbsoluteCm3);
                                    if (dv == "V")
                                    {
                                        value = doseValue.ToString("F2");
                                    }
                                    else if (dv == "CV")
                                    {
                                        value = (volume - doseValue).ToString("F2");
                                    }
                                }
                                else
                                {
                                    DoseValue dose      = doseUnit == "cGy" ? new DoseValue(vx * 100, DoseValue.DoseUnit.cGy) : new DoseValue(vx, DoseValue.DoseUnit.Gy);
                                    double    doseValue = planSetup.GetVolumeAtDose(s, dose, VolumePresentation.Relative);
                                    if (dv == "V")
                                    {
                                        value = doseValue.ToString("F2");
                                    }
                                    else if (dv == "CV")
                                    {
                                        value = (100.0 - doseValue).ToString("F2");
                                    }
                                }
                            }
                        }
                    }
                }

                double compare = Convert.ToDouble(value);
                double diff;
                var    ok_color  = Color.LightGreen;
                var    tol_color = Color.Yellow;
                var    ng_color  = Color.Red;

                // Compare to criterion
                if (sign != "" && critria != "")
                {
                    diff = compare - Convert.ToDouble(critria);
                    if (sign == "=")
                    {
                        if (Math.Abs(diff) < 0.01)
                        {
                            row.Cells[Column_result.Index].Style.BackColor = ok_color;
                        }
                        else
                        {
                            if (tol != "")
                            {
                                if (Math.Abs(diff) < Convert.ToDouble(tol))
                                {
                                    row.Cells[Column_result.Index].Style.BackColor = tol_color;
                                }
                                else
                                {
                                    row.Cells[Column_result.Index].Style.BackColor = ng_color;
                                }
                            }
                            else
                            {
                                row.Cells[Column_result.Index].Style.BackColor = ng_color;
                            }
                        }
                    }
                    else if (sign == "<=")
                    {
                        if (diff <= 0)
                        {
                            row.Cells[Column_result.Index].Style.BackColor = ok_color;
                        }
                        else
                        {
                            if (tol != "")
                            {
                                if (diff <= Convert.ToDouble(tol))
                                {
                                    row.Cells[Column_result.Index].Style.BackColor = tol_color;
                                }
                                else
                                {
                                    row.Cells[Column_result.Index].Style.BackColor = ng_color;
                                }
                            }
                            else
                            {
                                row.Cells[Column_result.Index].Style.BackColor = ng_color;
                            }
                        }
                    }
                    else if (sign == ">=")
                    {
                        if (diff >= 0)
                        {
                            row.Cells[Column_result.Index].Style.BackColor = ok_color;
                        }
                        else
                        {
                            if (tol != "")
                            {
                                if (diff >= -Convert.ToDouble(tol))
                                {
                                    row.Cells[Column_result.Index].Style.BackColor = tol_color;
                                }
                                else
                                {
                                    row.Cells[Column_result.Index].Style.BackColor = ng_color;
                                }
                            }
                            else
                            {
                                row.Cells[Column_result.Index].Style.BackColor = ng_color;
                            }
                        }
                    }
                }

                return(value);
            }
        }
Esempio n. 36
0
        /// <summary>
        /// event to delete the selected record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Delete_btn_Click(object sender, EventArgs e)
        {
            int selectedrowindex = Userdetails_dgv.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = Userdetails_dgv.Rows[selectedrowindex];

            messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colUserCode"].Value.ToString());

            DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text);

            if (dialogResult == DialogResult.OK)
            {
                UserVo inVo = new UserVo
                {
                    UserCode             = selectedRow.Cells["colUserCode"].Value.ToString(),
                    RegistrationDateTime = Convert.ToDateTime(DateTime.Now.ToString(UserData.GetUserData().DateTimeFormat)),
                    RegistrationUserCode = UserData.GetUserData().UserCode
                };

                try
                {
                    UserVo checkVo = CheckRelation(inVo);

                    if (checkVo != null)
                    {
                        StringBuilder message = new StringBuilder();

                        if (checkVo.RoleCount > 0)
                        {
                            message.Append(UserRelationTables.UserRole);
                        }

                        if (checkVo.FactoryCount > 0)
                        {
                            if (message.Length > 0)
                            {
                                message.Append(" And ");
                            }

                            message.Append(UserRelationTables.UserFactory);
                        }

                        if (checkVo.ProcessCount > 0)
                        {
                            if (message.Length > 0)
                            {
                                message.Append(" And ");
                            }

                            message.Append(UserRelationTables.UserProcess);
                        }

                        if (message.Length > 0)
                        {
                            messageData = new MessageData("mmce00007", Properties.Resources.mmce00007, message.ToString());
                            popUpMessage.Information(messageData, Text);
                            return;
                        }
                    }

                    UserVo outVo = (UserVo)InvokeCbm(new DeleteUserMasterMntCbm(), inVo, false);

                    if (outVo.AffectedCount > 0)
                    {
                        messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null);
                        logger.Info(messageData);
                        popUpMessage.Information(messageData, Text);

                        GridBind(FormConditionVo());
                    }
                    else if (outVo.AffectedCount == 0)
                    {
                        messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                        logger.Info(messageData);
                        popUpMessage.Information(messageData, Text);
                        GridBind(FormConditionVo());
                    }
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                }
            }
            else if (dialogResult == DialogResult.Cancel)
            {
                //do something else
            }
        }
Esempio n. 37
0
        // Edit/Update
        public DialogAdmin(MainForm form, DataGridViewRow row)
        {
            InitializeComponent();

            mainForm   = form;
            editUpdate = true;
            TXT_DialogAdminEmail.Enabled = false;
            Text = "Edit Administrator";
            GRPBOX_Admin.Text       = "Edit Administrator";
            BTN_DialogAdminAdd.Text = "Update Administrator";
            TXT_DialogAdminPassword.PasswordChar = passChar;

            TXT_DialogAdminEmail.MaxLength     = cmd.GetMaxLengthOfField("Users", "Email");
            TXT_DialogAdminFirstName.MaxLength = cmd.GetMaxLengthOfField("Users", "FirstName");
            TXT_DialogAdminLastName.MaxLength  = cmd.GetMaxLengthOfField("Users", "LastName");
            TXT_DialogAdminAddress.MaxLength   = cmd.GetMaxLengthOfField("Users", "Address");
            TXT_DialogAdminCity.MaxLength      = cmd.GetMaxLengthOfField("Users", "City");
            TXT_DialogAdminState.MaxLength     = cmd.GetMaxLengthOfField("Users", "State");
            TXT_DialogAdminPostcode.MaxLength  = cmd.GetMaxLengthOfField("Users", "Postcode");
            TXT_DialogAdminMobile.MaxLength    = cmd.GetMaxLengthOfField("Users", "Mobile");
            TXT_DialogAdminPassword.MaxLength  = cmd.GetMaxLengthOfField("Users", "Pass");
            TXT_DialogAdminGender.MaxLength    = cmd.GetMaxLengthOfField("Users", "Gender");

            TXT_DialogAdminEmail.Text     = row.Cells["Email"].Value.ToString();
            TXT_DialogAdminFirstName.Text = row.Cells["FirstName"].Value.ToString();
            TXT_DialogAdminLastName.Text  = row.Cells["LastName"].Value.ToString();
            TXT_DialogAdminAddress.Text   = row.Cells["Address"].Value.ToString();
            TXT_DialogAdminCity.Text      = row.Cells["City"].Value.ToString();
            TXT_DialogAdminState.Text     = row.Cells["State"].Value.ToString();
            TXT_DialogAdminPostcode.Text  = row.Cells["Postcode"].Value.ToString();
            // Get Password has it's own function
            TXT_DialogAdminPassword.Text = new MainDAL().GetPass(row.Cells["Email"].Value.ToString());

            string gender = row.Cells["Gender"].Value.ToString();

            if (gender == "Male")
            {
                RAD_DialogAdminGenderMale.Checked = true;
            }
            else if (gender == "Female")
            {
                RAD_DialogAdminGenderFemale.Checked = true;
            }
            else
            {
                RAD_DialogAdminGenderOther.Checked = true;
                TXT_DialogAdminGender.Enabled      = true;
                TXT_DialogAdminGender.Text         = row.Cells["Gender"].Value.ToString();
            }

            TXT_DialogAdminMobile.Text = row.Cells["Mobile"].Value.ToString();
            if (DateTime.TryParse(row.Cells["Dob"].Value.ToString(), out DateTime startDate))
            {
                DTP_DialogAdminDOB.Value   = startDate;
                DTP_DialogAdminDOB.Checked = true;
            }
            else
            {
                MessageBox.Show("Unable to load 'Birthdate' from database");
            }
        }
Esempio n. 38
0
        private void m_gridPlugins_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                m_gridFeatures.SuspendLayout();
                m_gridFeatures.Rows.Clear();

                if (m_gridPlugins.SelectedRows.Count < 1)
                {
                    return;
                }

                var pluginRow = m_gridPlugins.SelectedRows[0] as PluginRow;
                if (pluginRow == null)
                {
                    return;
                }

                var plugin = pluginRow.Plugin;

                //plugin version
                var version = string.IsNullOrEmpty(plugin.Version.ToString()) ? Messages.NONE : plugin.Version.ToString();
                m_gridFeatures.Rows.Add(new object[] { Messages.PLUGIN_VERSION, version });

                //plugin copyright
                var copyright = string.IsNullOrEmpty(plugin.Copyright) ? Messages.NONE : plugin.Copyright;
                m_gridFeatures.Rows.Add(new object[] { Messages.PLUGIN_COPYRIGHT, copyright });

                //plugin link
                var linkRow = new DataGridViewRow();
                linkRow.Cells.Add(new DataGridViewTextBoxCell {
                    Value = Messages.PLUGIN_LINK
                });

                if (string.IsNullOrEmpty(plugin.Link))
                {
                    linkRow.Cells.Add(new DataGridViewTextBoxCell {
                        Value = Messages.NONE
                    });
                }
                else
                {
                    linkRow.Cells.Add(new DataGridViewLinkCell {
                        Value = plugin.Link
                    });
                }

                m_gridFeatures.Rows.Add(linkRow);

                //feattures
                if (plugin.Features.Count > 0)
                {
                    var row = new DataGridViewRow();
                    row.Cells.AddRange(new DataGridViewCell[]
                    {
                        new DataGridViewTextBoxCell
                        {
                            Value = Messages.PLUGIN_FEATURES,
                            Style = new DataGridViewCellStyle {
                                Font = new Font(m_gridFeatures.Font, FontStyle.Bold)
                            }
                        },
                        new DataGridViewLinkCell {
                            Value = ""
                        }
                    });
                    m_gridFeatures.Rows.Add(row);

                    foreach (var feature in plugin.Features)
                    {
                        var label = string.IsNullOrEmpty(feature.Label) ? feature.Name : feature.Label;
                        m_gridFeatures.Rows.Add(new object[] { label, feature.Description });
                    }
                }
            }
            finally
            {
                m_gridFeatures.ResumeLayout();
            }
        }
Esempio n. 39
0
        private void DGV_PRODUCTS_DoubleClick(object sender, EventArgs e)
        {
            // get the selected product that you want to add to order
            DataGridViewRow selectedRow = DGV_PRODUCTS.CurrentRow;

            // call add quantity form
            FORM_QUANTITY fq = new FORM_QUANTITY();

            fq.pro_id = Convert.ToInt32(selectedRow.Cells[0].Value.ToString());
            fq.ShowDialog();

            int  index   = 0;
            bool isExist = false;                            // to test if the product is already add

            if (fq.addTheProduct)                            // test if the user cancel the add product to order | addTheProduct variable is declared in the quantity form
            {
                string qty            = fq.TB_QUANTITY.Text; // get the quantity from the quantity form
                double quantityXprice = Convert.ToInt32(qty) * Convert.ToDouble(selectedRow.Cells[3].Value.ToString());

                // if other products exist in the grid
                if (DGV_PRODUCTS_IN_ORDER.Rows.Count - 1 > 0)
                {
                    // check if the product is already add and set isExist to true
                    for (int i = 0; i < DGV_PRODUCTS_IN_ORDER.Rows.Count - 1; i++)
                    {
                        if (selectedRow.Cells[0].Value.ToString() == DGV_PRODUCTS_IN_ORDER.Rows[i].Cells[0].Value.ToString())
                        {
                            isExist = true;
                            index   = i;
                        }
                    }

                    // if the product already exist
                    // check the stock quantity
                    if (isExist)
                    {
                        // the quantity sum
                        int pqty = Convert.ToInt32(DGV_PRODUCTS_IN_ORDER.Rows[index].Cells[3].Value.ToString()) +
                                   Convert.ToInt32(qty);

                        DataTable table = new DataTable();
                        table = product.getProduct(Convert.ToInt32(selectedRow.Cells[0].Value.ToString()));

                        // if the quantity is heigher than the stock quantity than show a message
                        int qty2 = Convert.ToInt32(table.Rows[0]["STOCK_QTE"].ToString());
                        if (pqty > qty2)
                        {
                            MessageBox.Show("Unavailable Quantity", "Quantity", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        // if quantity is fine add the product
                        else
                        {
                            quantityXprice = quantityXprice = Convert.ToInt32(pqty) * Convert.ToDouble(selectedRow.Cells[3].Value.ToString());
                            DGV_PRODUCTS_IN_ORDER.Rows[index].Cells[3].Value = pqty.ToString();
                            DGV_PRODUCTS_IN_ORDER.Rows[index].Cells[4].Value = quantityXprice.ToString();
                            getTotal();
                        }
                    }

                    // if the product not exist => add product
                    else
                    {
                        DGV_PRODUCTS_IN_ORDER.Rows.Add(
                            selectedRow.Cells[0].Value.ToString(),
                            selectedRow.Cells[1].Value.ToString(),
                            selectedRow.Cells[3].Value.ToString(),
                            qty,
                            quantityXprice.ToString(),
                            false);
                        getTotal();
                    }
                }

                // if the gridview is empty => add product
                else if (DGV_PRODUCTS_IN_ORDER.Rows.Count - 1 == 0)
                {
                    DGV_PRODUCTS_IN_ORDER.Rows.Add(selectedRow.Cells[0].Value.ToString(),
                                                   selectedRow.Cells[1].Value.ToString(),
                                                   selectedRow.Cells[3].Value.ToString(),
                                                   qty,
                                                   quantityXprice.ToString(),
                                                   false);
                    getTotal();
                }

                getTotal();
            }
        }
Esempio n. 40
0
 internal static void IncarcaRandUltimaLucrare(DataGridViewRow pRand, BClientiComenzi pUltimaLucrare)
 {
     IncarcaRandUltimaLucrare(pRand, pUltimaLucrare, string.Empty);
 }
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View" }, allowRawJournalExport: true);

            if (frm.ShowDialog(this.FindForm()) == DialogResult.OK)
            {
                if (frm.ExportAsJournals)
                {
                    try
                    {
                        using (StreamWriter writer = new StreamWriter(frm.Path))
                        {
                            foreach (DataGridViewRow dgvr in dataGridViewJournal.Rows)
                            {
                                HistoryEntry he = dgvr.Cells[JournalHistoryColumns.HistoryTag].Tag as HistoryEntry;
                                if (dgvr.Visible && he.EventTimeLocal.CompareTo(frm.StartTime) >= 0 && he.EventTimeLocal.CompareTo(frm.EndTime) <= 0)
                                {
                                    string forExport = he.journalEntry.GetJson()?.ToString().Replace("\r\n", "");
                                    forExport = System.Text.RegularExpressions.Regex.Replace(forExport, "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1");
                                    writer.Write(forExport);
                                    writer.WriteLine();
                                }
                            }
                        }
                        if (frm.AutoOpen)
                        {
                            System.Diagnostics.Process.Start(frm.Path);
                        }
                    }
                    catch
                    {
                        ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    if (frm.SelectedIndex == 0)
                    {
                        BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                        grd.SetCSVDelimiter(frm.Comma);
                        grd.GetLineStatus += delegate(int r)
                        {
                            if (r < dataGridViewJournal.Rows.Count)
                            {
                                HistoryEntry he = dataGridViewJournal.Rows[r].Cells[JournalHistoryColumns.HistoryTag].Tag as HistoryEntry;
                                return((dataGridViewJournal.Rows[r].Visible &&
                                        he.EventTimeLocal.CompareTo(frm.StartTime) >= 0 &&
                                        he.EventTimeLocal.CompareTo(frm.EndTime) <= 0) ? BaseUtils.CSVWriteGrid.LineStatus.OK : BaseUtils.CSVWriteGrid.LineStatus.Skip);
                            }
                            else
                            {
                                return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                            }
                        };

                        grd.GetLine += delegate(int r)
                        {
                            DataGridViewRow rw = dataGridViewJournal.Rows[r];
                            return(new Object[] { rw.Cells[0].Value, rw.Cells[2].Value, rw.Cells[3].Value });
                        };

                        grd.GetHeader += delegate(int c)
                        {
                            return((c < 3 && frm.IncludeHeader) ? dataGridViewJournal.Columns[c + ((c > 0) ? 1 : 0)].HeaderText : null);
                        };

                        if (grd.WriteCSV(frm.Path))
                        {
                            if (frm.AutoOpen)
                            {
                                System.Diagnostics.Process.Start(frm.Path);
                            }
                        }
                        else
                        {
                            ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                }
            }
        }
Esempio n. 42
0
 internal static void IncarcaRandUltimaFactura(DataGridViewRow pRand, BClientiFacturi pUltimaFactura)
 {
     IncarcaRandUltimaFactura(pRand, pUltimaFactura, string.Empty);
 }
Esempio n. 43
0
            public void SimpleResults_DoubleClick(object sender, System.EventArgs e)
            {
                if ((SimpleResults.SelectedRows != null)&& SimpleResults.SelectedRows.Count > 0)
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    if (ItemSelectedEvent != null)
                        ItemSelectedEvent(new SPLookupFormItemSelectedEventArgs(SimpleResults.SelectedRows[0], SimpleResults.SelectedRows));

                    _FirstResult = SimpleResults.SelectedRows[0];
                    _SearchResults = SimpleResults.SelectedRows;
                }
            }
Esempio n. 44
0
 private void AgregarFila(DataGridViewRow r)
 {
     LocalidadesMetroGrid.Rows.Add(r);
 }
	// Constructors
	public DataGridViewCellCollection(DataGridViewRow dataGridViewRow) {}
Esempio n. 46
0
 private void SetearFila(DataGridViewRow r, Localidad localidad)
 {
     r.Cells[cmnLocalidad.Index].Value = localidad.NombreLocalidad;
     r.Cells[cmnProvincia.Index].Value = localidad.provincia.NombreProvincia;
     r.Tag = localidad;
 }
	// Constructors
	public DataGridViewRowCancelEventArgs(DataGridViewRow dataGridViewRow) {}
		public DataGridViewRowEventArgs (DataGridViewRow dataGridViewRow) {
			this.dataGridViewRow = dataGridViewRow;
		}