Пример #1
0
        protected void btnCreateSimcard_Click(object sender, EventArgs e)
        {
            string simnumber = rtxtSimnumber.Text.Trim();

            if (simnumber != "")
            {
                SimcardWithResult s = (SimcardWithResult)Simcard.GetSimcard(simnumber);

                if (s == null)
                {
                    s = new SimcardWithResult
                    {
                        Simnumber   = simnumber,
                        PUK         = "",
                        Number      = txtNumber.Text,
                        IsData      = false, //Ikke implementeret
                        FormatId    = 0,
                        QuotaId     = 1,     //Ikke implementeret
                        DataPlanId  = 1,     //Ikke implementeret
                        Provider    = rtxtProvider.Text,
                        UnitId      = int.Parse(ddlUnit.SelectedValue),
                        OrderNumber = "",
                        Notes       = $"Oprettet under mønstring {DateTime.Today.ToString("yyyyMMdd")}"
                    };

                    if (s.Save())
                    {
                        s.Result                 = "Oprettet";
                        phCreate.Visible         = false;
                        imgWarning.Visible       = false;
                        lblWarning.Visible       = false;
                        rptOtherSimcards.Visible = false;
                        lblSimnumber.Text        = simnumber;
                        hdnSimnumber.Value       = simnumber;
                    }
                    else
                    {
                        s.Result = "Noget gik galt";
                    }
                }
                else
                {
                    s.Result = "Findes i forvejen";
                }

                lblCreateMsg.Text    = s.Result;
                lblCreateMsg.Visible = true;
            }
        }
Пример #2
0
        protected void btnInsertMuster_Click(object sender, EventArgs e)
        {
            Validate("muster");

            if (Page.IsValid && gvInput.Rows.Count > 1)
            {
                DataAccessLayer dal     = new DataAccessLayer();
                List <string>   results = new List <string>(gvInput.Rows.Count);

                foreach (GridViewRow row in gvInput.Rows)
                {
                    if (row.RowType != DataControlRowType.DataRow)
                    {
                        break;
                    }

                    StringBuilder result = new StringBuilder();
                    result.Append($"Linje {row.Cells[0].Text}");

                    int taxTypeId = -1;

                    int.TryParse(((DropDownList)row.FindControl("ddlTaxType")).SelectedValue, out taxTypeId);

                    string imei        = ((HiddenField)((DeviceMusterInfo)row.FindControl("dhiDevice")).FindControl("hdnIMEI")).Value;
                    string simnumber   = ((HiddenField)((SimcardMusterInfo)row.FindControl("shiSimcard")).FindControl("hdnSimnumber")).Value;
                    string manr        = ((TextBoxWithOptions)row.FindControl("tbwoMANR")).Text.Trim();
                    string stabsnummer = ((TextBoxWithOptions)row.FindControl("tbwoStabsnummer")).Text.Trim();
                    string name        = ((TextBoxWithOptions)row.FindControl("tbwoName")).Text.Trim();

                    if (String.IsNullOrWhiteSpace(manr) && !chkbxStorageIfEmptyMANR.Checked)
                    {
                        result.Append(" Intet MANR!");
                    }
                    else
                    {
                        if (!String.IsNullOrWhiteSpace(imei))
                        {
                            if (Device.GetDevice(imei) is Device device)
                            {
                                dal.AddParameter("@ObjectTypeRefId", 3, DbType.Int16);
                                dal.AddParameter("@ObjectRefId", device.Id, DbType.Int32);
                                dal.AddParameter("@TaxTypeRefId", manr == "" ? null : (int?)taxTypeId, DbType.Int16);
                                dal.AddParameter("@MANR", manr == "" ? null : manr, DbType.String);
                                dal.AddParameter("@Stabsnummer", manr == "" ? null : stabsnummer, DbType.String);
                                dal.AddParameter("@Name", manr == "" ? null : name, DbType.String);
                                dal.AddParameter("@StatusRefId", manr == "" ? "1" : "4", DbType.Int16);
                                dal.AddParameter("@Notes", $"Mønstring {DateTime.Today.ToString("yyyyMMdd")}", DbType.String);
                                dal.AddParameter("@Executor", User.Identity.Name, DbType.String);
                                dal.ExecuteStoredProcedure("OrderInsert");
                                dal.ClearParameters();
                                result.Append($" IMEI OK!");
                            }
                            else
                            {
                                result.Append($" IMEI {imei} findes ikke!");
                            }
                        }

                        if (!String.IsNullOrWhiteSpace(simnumber))
                        {
                            if (Simcard.GetSimcard(simnumber) is Simcard simcard)
                            {
                                dal.AddParameter("@ObjectTypeRefId", 4, DbType.Int16);
                                dal.AddParameter("@ObjectRefId", simcard.Id, DbType.Int32);
                                dal.AddParameter("@TaxTypeRefId", manr == "" ? null : (int?)taxTypeId, DbType.Int16);
                                dal.AddParameter("@MANR", manr == "" ? null : manr, DbType.String);
                                dal.AddParameter("@Stabsnummer", manr == "" ? null : stabsnummer, DbType.String);
                                dal.AddParameter("@Name", manr == "" ? null : name, DbType.String);
                                dal.AddParameter("@StatusRefId", manr == "" ? "7" : "9", DbType.Int16);
                                dal.AddParameter("@Notes", $"Mønstring {DateTime.Today.ToString("yyyyMMdd")}", DbType.String);
                                dal.AddParameter("@Executor", User.Identity.Name, DbType.String);
                                dal.ExecuteStoredProcedure("OrderInsert");
                                dal.ClearParameters();
                                result.Append($" SIM OK!");
                            }
                            else
                            {
                                result.Append($" SIM {simnumber} findes ikke!");
                            }
                        }
                    }

                    results.Add(result.ToString());
                }

                txtResult.Text    = "";
                txtResult.Visible = true;

                foreach (String line in results)
                {
                    txtResult.Text += $"{line}\n";
                }

                SetMessage("<br />Rækker kørt!<br /><br/>");
                btnInsertMuster.Visible = false;
            }
        }