Example #1
0
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            modUpdatePanel.Update();

            int objectID = -1;

            if (Gridview.SelectedDataKey != null)
            {
                objectID = Convert.ToInt16(Gridview.SelectedDataKey.Value.ToString());
            }
            List <ClientCode> selectedObject = _businesscode.GetClients($"WHERE Client_ID = {objectID}");

            if (objectID == -1)
            {
                if (tbName.Text != string.Empty)
                {
                    UserCode LoginUser = (UserCode)Session["authenticatedUser"];
                    UserCode user      = GetCurrentUser(LoginUser.ID);

                    ClientCode newObject = new ClientCode(0, tbName.Text, tbAdress.Text, tbPostalCode.Text, tbCity.Text, tbCountry.Text, tbContactPerson.Text, tbInvoiceInfo.Text, tbKindOfClient.Text, user.ID, DateTime.Now, DateTime.Now);
                    _businesscode.AddClient(newObject);

                    lbError.Text      = "User successfully created";
                    lbError.Visible   = true;
                    lbError.ForeColor = System.Drawing.Color.Green;

                    Load_content();
                    gvUpdatePanel.Update();
                }
                else
                {
                    lbError.Text    = "Please fill in all required fields";
                    lbError.Visible = true;
                }
            }
            else
            {
                if (tbName.Text != string.Empty)
                {
                    UserCode LoginUser = (UserCode)Session["authenticatedUser"];
                    UserCode user      = GetCurrentUser(LoginUser.ID);

                    ClientCode Object = new ClientCode(0, tbName.Text, tbAdress.Text, tbPostalCode.Text, tbCity.Text, tbCountry.Text, tbContactPerson.Text, tbInvoiceInfo.Text, tbKindOfClient.Text, user.ID, DateTime.Now, DateTime.Now);
                    _businesscode.UpdateClient(Object);

                    lbError.Text      = "User successfully updated";
                    lbError.Visible   = true;
                    lbError.ForeColor = System.Drawing.Color.Green;

                    Load_content();
                    gvUpdatePanel.Update();
                }
                else
                {
                    lbError.Text    = "Please fill in all required fields";
                    lbError.Visible = true;
                }
            }
        }
Example #2
0
        private void SendData()
        {
            for (int i = 0; i <= 9; i++)
            {
                string[] input = new string[8];

                for (int i2 = 0; i2 <= 7; i2++)
                {
                    string tbName    = "tbEdit" + i.ToString() + i2.ToString();
                    var    container = Master.FindControl("Body");
                    var    txtBox    = container.FindControl(tbName);

                    switch (i2)
                    {
                    case 0:
                        if (((TextBox)txtBox).Text != "")
                        {
                            input[i2] = _businesscode.BeginUpperCase((((TextBox)txtBox).Text.ToString()));
                        }
                        else
                        {
                            goto track1;
                        }
                        break;

                    case 1:
                        input[i2] = _businesscode.BeginUpperCase((((TextBox)txtBox).Text.ToString()));
                        break;

                    case 2:
                        input[i2] = (((TextBox)txtBox).Text.ToString());
                        break;

                    case 3:
                        input[i2] = _businesscode.BeginUpperCase((((TextBox)txtBox).Text.ToString()));
                        break;

                    case 4:
                        input[i2] = _businesscode.BeginUpperCase((((TextBox)txtBox).Text.ToString()));
                        break;

                    case 5:
                        input[i2] = _businesscode.BeginUpperCase((((TextBox)txtBox).Text.ToString()));
                        break;

                    case 6:
                        input[i2] = (((TextBox)txtBox).Text.ToString());
                        break;

                    case 7:
                        input[i2] = _businesscode.BeginUpperCase((((TextBox)txtBox).Text.ToString()));
                        break;
                    }
                }

                UserCode LoginUser = (UserCode)Session["authenticatedUser"];
                UserCode user      = GetCurrentUser(LoginUser.ID);

                ClientCode client = new ClientCode(0, input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], user.ID, DateTime.Now, DateTime.Now);
                _businesscode.AddClient(client);
track1:
                continue;
            }
        }