コード例 #1
0
 private void btn_save_Click(object sender, EventArgs e)
 {
     if (condition_meet())
     {
         string
             item_name      = cmb_name.Text,
             item_type      = cmb_type.Items[cmb_type.SelectedIndex].ToString(),
             item_craftable = cmb_craftable.Items[cmb_craftable.SelectedIndex].ToString();
         int
             item_level       = Convert.ToInt32(txt_level.Text),
             item_craft_level = Convert.ToInt32(txt_craft_level.Text),
             item_craft_exp   = Convert.ToInt32(txt_craft_exp.Text),
             item_craft_batch = Convert.ToInt32(txt_craft_batch.Text),
             item_price       = Convert.ToInt32(txt_price.Text);
         progressBar1.Value = 100;
         if (btn_save.Text == "Save")
         {
             string q = @"insert into tbl_item values('" + item_name + "','" + item_type + "','" + item_craftable + "'," + item_level + "," + item_craft_level + "," + item_craft_exp + "," + item_craft_batch + "," + item_price + ")";
             MessageBox.Show(lite.insert_data(q) + " data telah tersimpan", "Informasi", MessageBoxButtons.OK);
         }
         else if (btn_save.Text == "Update")
         {
             string q = @"update tbl_item set item_name='" + item_name + "', item_type='" + item_type + "', item_craftable='" + item_craftable + "', item_level=" + item_level + ", item_craft_level=" + item_craft_level + ", item_craft_exp=" + item_craft_exp + ", item_craft_batch=" + item_craft_batch + ", item_price=" + item_price + " where item_name='" + item_name + "'";
             MessageBox.Show(lite.insert_data(q) + " data telah terupdate", "Informasi", MessageBoxButtons.OK);
         }
         susun_item();
         item_check();
     }
     else
     {
         MessageBox.Show("Silahkan isi form yang kosong", "Informasi", MessageBoxButtons.OK);
     }
 }
コード例 #2
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            int    count   = 0; harga = 0;
            string message = "";

            foreach (Control c in panel_item.Controls)
            {
                if (c.GetType() == typeof(EasyCompletionComboBox))
                {
                    count += 1;
                }
            }
            string[] list_item = new string[count];
            for (int i = 0; i < count; i++)
            {
                string s =
                    ((EasyCompletionComboBox)panel_item.Controls.Find("cmb_nma_" + i.ToString(), true)[0]).Text + "(" +
                    ((TextBox)panel_item.Controls.Find("txt_jlh_" + i.ToString(), true)[0]).Text + ")";
                list_item[i] = s;
                q            = @"update tbl_item set item_price=" +
                               Convert.ToInt32(((TextBox)panel_item.Controls.Find("txt_hrg_" + i.ToString(), true)[0]).Text) +
                               " where item_name='" +
                               ((EasyCompletionComboBox)panel_item.Controls.Find("cmb_nma_" + i.ToString(), true)[0]).Text + "'";
                lite.insert_data(q);
                harga += (
                    Convert.ToInt32(((TextBox)panel_item.Controls.Find("txt_jlh_" + i.ToString(), true)[0]).Text) *
                    Convert.ToInt32(((TextBox)panel_item.Controls.Find("txt_hrg_" + i.ToString(), true)[0]).Text));
            }
            string recipe = string.Join(",", list_item);

            if (btn_save.Text == "Save")
            {
                q       = @"insert into tbl_craft values('" + txt_item_name.Text + "','" + recipe + "')";
                message = "tersimpan";
                //MessageBox.Show(lite.insert_data(q).ToString() + " Data telah tersimpan", "Informasi", MessageBoxButtons.OK);
            }
            else if (btn_save.Text == "Update")
            {
                q       = @"update tbl_craft set craft_recipe='" + recipe + "' where craft_name='" + txt_item_name.Text + "'";
                message = "terupdate";
                //MessageBox.Show(lite.insert_data(q).ToString() + " Data telah terupdate", "Informasi", MessageBoxButtons.OK);
            }
            int hsl = lite.insert_data(q);

            if (sender != null)
            {
                MessageBox.Show(hsl.ToString() + " Data telah " + message, "Informasi", MessageBoxButtons.OK);
            }
            q = @"select item_craft_batch from tbl_item where item_name='" + txt_item_name.Text + "'";
            int batch = Convert.ToInt32(lite.get_datacell(q));

            harga = harga / batch;
            q     = @"update tbl_item set item_price=" + harga + " where item_name='" + txt_item_name.Text + "'";
            lite.insert_data(q);
            ((form_item)this.Owner).item_check();
            //check_craft();
        }
コード例 #3
0
 private void btn_simpan_Click(object sender, EventArgs e)
 {
     if (condition_meet())
     {
         string query = "";
         string
             item_name      = txt_nama_adv.Text,
             item_type      = combo_jenis_adv.Items[combo_jenis_adv.SelectedIndex].ToString(),
             item_craftable = combo_c_able.Items[combo_c_able.SelectedIndex].ToString();
         int
             item_level       = Convert.ToInt32(txt_level.Text),
             item_craft_level = Convert.ToInt32(txt_c_level.Text),
             item_craft_exp   = Convert.ToInt32(txt_c_exp.Text),
             item_craft_batch = Convert.ToInt32(txt_c_batch.Text),
             item_price       = Convert.ToInt32(txt_harga_adv.Text),
             item_tree        = Convert.ToInt32(txt_tree.Text);
         if (btn_simpan.Text == "Simpan")
         {
             query = @"insert into tbl_item values('" + item_name + "','" + item_type + "','" + item_craftable + "'," + item_level + "," + item_craft_level + "," + item_craft_exp + "," + item_craft_batch + "," + item_price + "," + item_tree + ")";
             MessageBox.Show(lite.insert_data(query) + " data telah tersimpan", "Informasi", MessageBoxButtons.OK);
         }
         else if (btn_simpan.Text == "Update")
         {
             query = @"update tbl_item set item_name='" + item_name + "', item_type='" + item_type + "', item_craftable='" + item_craftable + "', item_level=" + item_level + ", item_craft_level=" + item_craft_level + ", item_craft_exp=" + item_craft_exp + ", item_craft_batch=" + item_craft_batch + ", item_price=" + item_price + ", item_tree_level=" + item_tree + " where item_name='" + item_name + "'";
             MessageBox.Show(lite.insert_data(query) + " data telah terupdate", "Informasi", MessageBoxButtons.OK);
         }
         if (item_craftable == "yes")
         {
             simpan_craft();
         }
         txt_nama_adv.Text = "";
         txt_nama_adv.Text = item_name;
     }
     else
     {
         MessageBox.Show("Silahkan isi data yang diperlukan", "Informasi", MessageBoxButtons.OK);
     }
 }
コード例 #4
0
 private void btn_save_Click(object sender, EventArgs e)
 {
     if (combo_name.SelectedIndex > -1)
     {
         int count = 0;
         foreach (Control c in panel_data.Controls)
         {
             if (c.GetType() == typeof(TextBox))
             {
                 count += 1;
             }
         }
         if (count > 0)
         {
             var      list_txt      = new List <TextBox>();
             string   recipe        = "";
             string[] item          = new string[count];
             bool     recipe_status = false;
             for (int i = 0; i < count; i++)
             {
                 var cmb = (EasyCompletionComboBox)panel_data.Controls.Find("cmb_add_" + i.ToString(), true)[0];
                 if (cmb.SelectedIndex < 0)
                 {
                     MessageBox.Show("Silahkan pilih recipe item", "Informasi", MessageBoxButtons.OK);
                     recipe_status = false;
                     break;
                 }
                 else
                 {
                     recipe_status = true;
                 }
                 var txt = (TextBox)panel_data.Controls.Find("txt_add_" + i.ToString(), true)[0];
                 if (txt.Text == "" || txt.Text == "0")
                 {
                     MessageBox.Show("Silahkan isi jumlah item", "Informasi", MessageBoxButtons.OK);
                     recipe_status = false;
                     break;
                 }
                 else
                 {
                     recipe_status = true;
                 }
                 item[i] = cmb.Items[cmb.SelectedIndex].ToString() + "(" + txt.Text + ")";
             }
             if (recipe_status)
             {
                 recipe = string.Join(",", item);
                 string target_item = combo_name.Items[combo_name.SelectedIndex].ToString();
                 if (target_item == lite.get_datacell(@"select recipe_name from tbl_recipe where recipe_name ='" + target_item + "'", conn).ToString())
                 {
                     MessageBox.Show("Recipe item sudah ada", "Informasi", MessageBoxButtons.OK);
                 }
                 else
                 {
                     string query = @"insert into tbl_recipe values ('" + target_item + "','" + recipe + "')";
                     MessageBox.Show(lite.insert_data(query, conn).ToString() + " Data telah tersimpan", "Informasi", MessageBoxButtons.OK);
                 }
             }
         }
         else
         {
             MessageBox.Show("Silahkan isi kombinasi item", "Informasi", MessageBoxButtons.OK);
         }
     }
     else
     {
         MessageBox.Show("Silahkan pilih item", "Informasi", MessageBoxButtons.OK);
     }
 }