public TN(String s) : base() { Part.Add(new ENXP(s) { Type = null }); }
private async void Save(object sender, EventArgs e) { _this.Name = txtName.Text; _this.Description = txtDescription.Text; _this.EAN = txtEAN.Text; _this.ProducentsCode = txtProducersCode.Text; _this.Symbol = txtSymbol.Text; _this.Destination = txtDestination.Text; _this.Appliance = txtAppliance.Text; _this.UsedOn = txtUsedOn.Text; _this.IsArchived = cboxArchived.CheckState.CheckboxStateToNullableBool(); _this.ProducerId = cmbProducer.GetSelectedValue <Company>(); _this.SupplierId = cmbSupplier.GetSelectedValue <Company>(); string photoPath = null; if (img.Items.Any()) { if (img.Items[0].IsUploaded != true) { photoPath = img.Items[0].Link; } } try { Looper.Show(this); string res = string.Empty; if (mode == 1) { _this.CreatedBy = RuntimeSettings.UserId; _this.CreatedOn = DateTime.Now; if (await _this.Add(photoPath)) { mode = 2; this.Text = "Szczegóły części"; GenerateQrCode(_this.Token); EnableButtons(); } } else if (mode == 2) { res = await _this.Edit(photoPath); } res = await files.Save($"PartId={_this.PartId}"); if (res != "OK") { MessageBox.Show($"Wystąpiły problemy podczas zapisywania plików. Szczegóły: {res}", "Problemy", buttons: MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Błąd podczas zapisywania", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Looper.Hide(); } }
protected virtual IDictionary <int, Part> ConvertStringToParts(string partsString) { if (string.IsNullOrEmpty(partsString)) { return(new Dictionary <int, Part>()); } var dict = ConvertToTrackFormat(partsString); return(dict.ToDictionary(k => k.Key, v => { var part = new Part(); var noteParts = v.Value; foreach (var notePart in noteParts) { var notePartKey = notePart.Key; var notePartValue = notePart.Value; if (notePartKey == -1) { //Set all key part.AllPartType = (PartType)notePartValue[0]; } else { var notes = new List <NotePart>(); var notesStr = SpecialSplit(notePartValue); foreach (var noteStr in notesStr) { var note = new NotePart { PartType = (PartType)noteStr[0] }; if (noteStr.Any(char.IsDigit)) { note.Length = int.Parse(noteStr.Substring(1, noteStr.Length - 1)); } notes.Add(note); } //set partial key part.Add(notePartKey, notes); } } return part; })); }
public void Write(Part part) { Part imgPart = new Part(PartType.Image); imgPart.WriteInt(Width); imgPart.WriteInt(Height); imgPart.WriteString(Name); for (int i = 0; i < this.Count; i++) { this[i].Write(imgPart); } part.Add(imgPart); }
public void Write(Part part) { if (this.Count != this.Columns * this.Rows) { throw new Exception("A quantidade de bricks deve ser a quantidade de colunas pela quantidade de linhas"); } Part mapPart = new Part(PartType.Map); mapPart.WriteInt(Columns); mapPart.WriteInt(Rows); mapPart.WriteInt(TileWidth); mapPart.WriteInt(TileHeight); mapPart.WriteString(Name); for (int i = 0; i < this.Count; i++) { mapPart.WriteInt(this[i]); } part.Add(mapPart); }
private void button4_Click(object sender, EventArgs e) { string site = cmb_site.SelectedValue.ToString(); string partno = cmb_partno.Text.Trim().ToString(); string partspec = cmb_partname.Text.Trim().ToString(); string parttype = tb_type.Text.Trim().ToString(); string partmat = tb_mat.Text.Trim().ToString(); string partlevel = tb_level.Text.Trim().ToString(); string partcert = tb_cert.Text.Trim().ToString(); string purchasec = tb_pc.Text.Trim().ToString(); string spec1 = tb_spec1.Text.Trim().ToString(); string spec2 = tb_spec2.Text.Trim().ToString(); string spec3 = tb_spec3.Text.Trim().ToString(); string spec4 = tb_spec4.Text.Trim().ToString(); string partunit = tb_unit.Text.Trim().ToString(); string partunitdestiny = tb_unitdestiny.Text.Trim().ToString(); string partdestinyunit = txt_destinyunit.Text.Trim().ToString(); //if (ProjectId == string.Empty) //{ // MessageBox.Show("请选择项目!"); // return; //} if (partno == string.Empty) { MessageBox.Show("请填写零件编号!"); return; } if (Part.Exist(partno)) { MessageBox.Show("此零件编号已经存在,请检查!"); return; } if (partspec == string.Empty) { MessageBox.Show("请填写零件规格!"); return; } if (parttype == string.Empty) { MessageBox.Show("请填写零件类型!"); return; } if (partmat == string.Empty) { MessageBox.Show("请填写零件材质!"); return; } if (partcert == string.Empty) { MessageBox.Show("请填写零件证书!"); return; } if (partlevel == string.Empty) { MessageBox.Show("请填写零件等级!"); return; } try { DataSet unitds = PartParameter.QueryPartPara("select name from mm_unit_tab"); //string partno = dgv1.Rows[i].Cells["零件号"].Value.ToString().Trim(); //PartParameter pp = PartParameter.Find(ProjectId, partno, site, LoginUser); Part ppn = new Part(); ppn.PART_NO = partno; ppn.CONTRACT = site; ppn.PARENTID = int.Parse(activity); ppn.PART_CERT = partcert; if (partunitdestiny != string.Empty) { ppn.PART_UNITDENSITY = decimal.Parse(partunitdestiny); } if (partdestinyunit != string.Empty) { ppn.PART_DENSITYUNIT = partdestinyunit; } ppn.PART_LEVEL = partlevel; ppn.PART_SPEC = partspec; ppn.PART_SPEC1 = spec1; ppn.PART_SPEC2 = spec2; ppn.PART_SPEC3 = spec3; ppn.PART_SPEC4 = spec4; ppn.CREATOR = LoginUser; ppn.PART_UNIT = partunit; ppn.PART_MAT = partmat; ppn.PART_TYPE = parttype; if (purchasec != string.Empty) { ppn.SUPPLYCIRCLE = int.Parse(purchasec); } else { ppn.SUPPLYCIRCLE = 10; } #region 判断Unit是否是合格格式 DataRow[] pone = unitds.Tables[0].Select("name ='" + partunit + "'"); if (pone.Length != 0) { ppn.PART_UNIT = partunit; } else { MessageBox.Show("单位名称不规范,请检查!", "错误提示"); tb_unit.Focus(); return; } #endregion int count = ppn.Add(); if (count == 0) { MessageBox.Show("添加失败"); return; } MessageBox.Show("保存零件成功!! ", "温馨提示!"); QuerydataBind(); #region //int cou = PartParameter.GetSpecCou(activity); //DataGridViewRow newrow = new DataGridViewRow(); //dgv1.Rows.Insert(0, newrow); //newrow.CreateCells(dgv1); //newrow.Cells[11 + cou].Value = site; //if (cou > 0) //{ // newrow.Cells[4].Value = spec1; //} //if (cou > 1) //{ // newrow.Cells[5].Value = spec2; //} //if (cou > 2) //{ // newrow.Cells[6].Value = spec3; //} //if (cou > 3) //{ // newrow.Cells[7].Value = spec4; //} //newrow.Cells[2].Value = parttype; //newrow.Cells[3].Value = partspec; //newrow.Cells[4+cou].Value = partmat; //newrow.Cells[5 + cou].Value = partcert; //newrow.Cells[6 + cou].Value = partunit; ////newrow.Cells["密度单位"].Value = partunit; //newrow.Cells[9 + cou].Value = partlevel; //newrow.Cells[7 + cou].Value = partunitdestiny; //newrow.Cells[10 + cou].Value = activity; //dgv1.Rows.Add(newrow); #endregion } catch (Exception err) { MessageBox.Show("错误原因:" + err.Message, "错误提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } }