private void KiGui()
        {
            try
            {
                SqlConnection Con = KetNoiCSDL.KetNoiSQL();
                Con.Open();


                Class.KiGuiHangHoa HangHoa = new Class.KiGuiHangHoa();

                //idChuyen
                int index = lblMaVe.Text.IndexOf(" ");

                HangHoa.IdChuyen = lblMaVe.Text.Substring(index + 3);

                //Ten
                HangHoa.TenNguoiGui  = txtTenNguoiGui.Text.ToString();
                HangHoa.TenNguoiNhan = txtTenNguoiNhan.Text.ToString();

                //CMND
                HangHoa.CMNDNguoiGui  = ntxtCMNDNguoiGui.Text.ToString();
                HangHoa.CMNDNguoiNhan = ntxtCMNDNguoiNhan.Text.ToString();

                //SDT

                HangHoa.SDTNguoiGui  = ntxtSDTNguoiGui.Text.ToString();
                HangHoa.SDTNguoiNhan = ntxtSDTNguoiNhan.Text.ToString();

                //Hàng Hoá
                HangHoa.TenMonHang = txtTenHang.Text.ToString();
                HangHoa.KichThuoc  = txtKichThuoc.Text.ToString();
                HangHoa.TrongLuong = ntxtTrongLuong.Text.ToString();

                //Tien


                string TempTien  = TextBoxGiaTien.Text;
                int    ixdexTien = TextBoxGiaTien.Text.IndexOf(".");
                if (ixdexTien == -1)
                {
                    HangHoa.ChiPhiGui = Convert.ToInt32(TempTien);
                }
                else
                {
                    TempTien          = TempTien.Replace(".", "");
                    HangHoa.ChiPhiGui = Convert.ToInt32(TempTien);
                }

                string KiGui = string.Format("exec KiGui @TenNguoiGui, @SDTNguoiGui, @CMNDNguoiGui, @TenNguoiNhan, @SDTNguoiNhan, @CMNDNguoiNhan, @TenMonHang, @TrongLuong, @KichThuoc, @ChiPhiGui, @IdChuyen");

                string    InsertNhatKi = string.Format("exec InsertNhatKi @TenNguoiGui,@SDTNguoiGui,@CMNDNguoiGui,@LoaiGiaoDichGui");
                DataTable user         = new DataTable();

                SqlCommand Com      = new SqlCommand(KiGui, Con);
                SqlCommand ComUuDai = new SqlCommand(InsertNhatKi, Con);

                //KiGui
                Com.Parameters.Add(new SqlParameter("@TenNguoiGui", HangHoa.TenNguoiGui));
                Com.Parameters.Add(new SqlParameter("@SDTNguoiGui", HangHoa.SDTNguoiGui));
                Com.Parameters.Add(new SqlParameter("@CMNDNguoiGui", HangHoa.CMNDNguoiGui));
                Com.Parameters.Add(new SqlParameter("@TenNguoiNhan", HangHoa.TenNguoiNhan));
                Com.Parameters.Add(new SqlParameter("@SDTNguoiNhan", HangHoa.SDTNguoiNhan));
                Com.Parameters.Add(new SqlParameter("@CMNDNguoiNhan", HangHoa.CMNDNguoiNhan));
                Com.Parameters.Add(new SqlParameter("@TenMonHang", HangHoa.TenMonHang));
                Com.Parameters.Add(new SqlParameter("@TrongLuong", HangHoa.TrongLuong));
                Com.Parameters.Add(new SqlParameter("@KichThuoc", HangHoa.KichThuoc));
                Com.Parameters.Add(new SqlParameter("@ChiPhiGui", HangHoa.ChiPhiGui));
                Com.Parameters.Add(new SqlParameter("@IdChuyen", HangHoa.IdChuyen));



                //InsertNhatKiKhachHangGui
                ComUuDai.Parameters.Add(new SqlParameter("@TenNguoiGui", HangHoa.TenNguoiGui));
                ComUuDai.Parameters.Add(new SqlParameter("@SDTNguoiGui", HangHoa.SDTNguoiGui));
                ComUuDai.Parameters.Add(new SqlParameter("@CMNDNguoiGui", HangHoa.CMNDNguoiGui));
                ComUuDai.Parameters.Add(new SqlParameter("@LoaiGiaoDichGui", "Gửi Hàng" + " - " + HangHoa.TenMonHang));



                SqlDataAdapter adapt  = new SqlDataAdapter(Com);
                SqlDataAdapter adapt1 = new SqlDataAdapter(ComUuDai);
                adapt.Fill(user);
                adapt1.Fill(user);
                Con.Close();
                MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Đặt Hàng :{0}: Cho Khách Hàng: {1}!", HangHoa.TenMonHang, HangHoa.TenNguoiGui));
            }
            catch (Exception EX)
            {
                MetroFramework.MetroMessageBox.Show(this, EX.Message);
            }
        }
Example #2
0
        private void btnNhanHang_Click(object sender, EventArgs e)
        {
            if (MetroFramework.MetroMessageBox.Show(this, "Chắc Chắn Hay Không", "Bạn Có Chắc Huỷ Vé Này", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Class.KiGuiHangHoa HangHoa = new Class.KiGuiHangHoa();



                //Ten

                HangHoa.TenNguoiNhan = txtTenNguoiNhan.Text.ToString();

                //CMND
                HangHoa.CMNDNguoiNhan = ntxtCMNDNguoiNhan.Text.ToString();

                //SDT

                HangHoa.SDTNguoiNhan = ntxtSDTNguoiNhan.Text.ToString();

                //Hàng Hoá
                HangHoa.TenMonHang = txtTenHang.Text.ToString();


                string IdHangHoa = IdHangCanDoi;
                string IdChuyen  = IdChuyenCanDoi;

                try
                {
                    SqlConnection Con = KetNoiCSDL.KetNoiSQL();
                    Con.Open();
                    DataTable user        = new DataTable();
                    string    NhanHang    = string.Format("exec  NhanHang   @IdChuyen ,@IdHangHoa");
                    string    InsertNikki = string.Format("exec InsertNikki @TenNguoiNhan,@SDTNguoiNhan,@CMNDNguoiNhan,@LoaiGiaoDichNhan");

                    //Insert NhatKyNguoiDung
                    SqlCommand ComUuDai = new SqlCommand(InsertNikki, Con);
                    //dat hang
                    SqlCommand Com = new SqlCommand(NhanHang, Con);

                    Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen));
                    Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa));


                    //InsertUuDaiKhachHang

                    //InsertNhatKiKhachHangNhan
                    ComUuDai.Parameters.Add(new SqlParameter("@TenNguoiNhan", HangHoa.TenNguoiNhan));
                    ComUuDai.Parameters.Add(new SqlParameter("@SDTNguoiNhan", HangHoa.SDTNguoiNhan));
                    ComUuDai.Parameters.Add(new SqlParameter("@CMNDNguoiNhan", HangHoa.CMNDNguoiNhan));
                    ComUuDai.Parameters.Add(new SqlParameter("@LoaiGiaoDichNhan", "Nhận Hàng" + " - " + HangHoa.TenMonHang));

                    //
                    SqlDataAdapter adapt1 = new SqlDataAdapter(ComUuDai);
                    SqlDataAdapter adapt  = new SqlDataAdapter(Com);
                    adapt.Fill(user);
                    adapt1.Fill(user);

                    Con.Close();

                    MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Trao Hàng  Mã Số:{0}", IdHangCanDoi + " - " + IdChuyenCanDoi));
                    NhanHang_Load(sender, e);
                    metroPanel1.Visible = false;
                    btnNhanHang.Visible = false;
                }
                catch (Exception EX)
                {
                    MetroFramework.MetroMessageBox.Show(this, EX.Message);
                }
            }
        }