protected void PopolaCodCantAnnoNumero(string anno, string num = "") { string numCant = ""; if (num == "") { List <Cantieri> items = CantieriDAO.GetAll().Where(w => w.Anno == Convert.ToInt32(anno)).ToList(); if (items.Count > 0) { txtNumeroCant.Text = (items.Select(s => s.Numero).Max() + 1).ToString() ?? ""; } else { txtNumeroCant.Text = "001"; } numCant = txtNumeroCant.Text; } else { numCant = num; } if (numCant.Length == 1) { numCant = "00" + numCant; } else if (numCant.Length == 2) { numCant = "0" + numCant; } txtCodCant.Text = anno.Substring(2, 2) + numCant + "Ma"; }
protected string CostruisciCodRiferCant() { DateTime date = DateTime.Now; int numCant = CantieriDAO.GetAll().Where(w => w.Anno == Convert.ToInt32(txtAnnoCant.Text)).Count(); int descrLength = txtDescrCodCant.Text.Trim().Length; string firstTwoDescrCodCant = txtDescrCodCant.Text.Substring(0, 2); string lastYearDigits = date.Year.ToString().Substring(2, 2); string firstTwoRagSocCli = ddlScegliClientePerCantiere.SelectedItem.Text.Substring(0, 2); string codRiferCant = Convert.ToString(numCant + descrLength) + firstTwoDescrCodCant + lastYearDigits + firstTwoRagSocCli; return(codRiferCant.Replace(" ", "-").ToUpper()); }
protected void FillDdlScegliCantiere() { ddlScegliCantiere.Items.Clear(); ddlScegliCantiere.Items.Add(new ListItem("", "-1")); DropDownListManager.FillDdlCantieri(CantieriDAO.GetAll().Where(w => !w.Chiuso).ToList(), ref ddlScegliCantiere); }