Beispiel #1
0
        public static int UpdateServiceTrans(SERVICE_TRANS_DTO service)
        {
            provider.connect();
            string sqlCommand        = "sp_UpdateServiceTrans";
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@madv", service.MaDV));
            list.Add(new SqlParameter("@tencty", service.TenCongTy));
            list.Add(new SqlParameter("@linkws", service.LinkWebService));
            // list.Add(new SqlParameter("@username",service.UserName));
            // list.Add(new SqlParameter("@password",service.PassWord));
            list.Add(new SqlParameter("@website", service.Website));
            list.Add(new SqlParameter("@tinhtrang", service.TinhTrang));
            SqlParameter result = new SqlParameter("@result", SqlDbType.Int);

            result.Direction = ParameterDirection.ReturnValue;
            list.Add(result);
            try
            {
                provider.executeNonQueryProcedure(sqlCommand, list);
                return((int)result.Value);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                provider.disconnect();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            SERVICE_TRANS_DTO service = new SERVICE_TRANS_DTO();

            service.TenCongTy      = txtName.Text;
            service.LinkWebService = txtLink.Text;
            service.MaDV           = int.Parse(hdfId.Value);
            service.TinhTrang      = int.Parse(DropDownList1.SelectedValue);
            service.Website        = txtWebsite.Text;
            try
            {
                int result = ServiceTransBUS.UpdateServiceTrans(service);
                if (result == 1)
                {
                    lbResult.ForeColor = Color.Green;
                    lbResult.Text      = "Đã cập nhật thành công";
                }
                else
                {
                    lbResult.ForeColor = Color.Red;
                    lbResult.Text      = "Đã có lỗi , xin vui lòng thử lại sau";
                }
            }
            catch (Exception ex)
            {
                lbResult.ForeColor = Color.Red;
                lbResult.Text      = "Đã có lỗi , xin vui lòng thử lại sau";
            }
        }
Beispiel #3
0
        public static TransportCompany[] GetTransportCompany()
        {
            TransportCompany[] companny = GeneralPurchasingDAO.GetTransportCompany();
            foreach (TransportCompany cp in companny)
            {
                int madv = 0;
                int.TryParse(cp.MaCongTyVanChuyen, out madv);
                SERVICE_TRANS_DTO          sv    = GeneralPurchasingDAO.GetInfoServiceTrans(madv);
                VanChuyen.FedexWebService1 proxy = new BizWebservice.VanChuyen.FedexWebService1();
                proxy.Url = sv.LinkWebService;
                //string sid = proxy.Authenticate(sv.UserName, sv.PassWord);
                VanChuyen.TransportCompany tr = proxy.GetTranports();

                int n = tr.HinhThucVanChuyen.Length;
                cp.HinhThucVanChuyen = new TransportType[n];
                if (tr != null)
                {
                    cp.TenCongTyVanChuyen = tr.TenCongTyVanChuyen;
                    for (int i = 0; i < n; i++)
                    {
                        cp.HinhThucVanChuyen[i] = new TransportType();
                        cp.HinhThucVanChuyen[i].MaHinhThucVanChuyen  = tr.HinhThucVanChuyen[i].MaHinhThucVanChuyen;
                        cp.HinhThucVanChuyen[i].TenHinhThucVanChuyen = tr.HinhThucVanChuyen[i].TenHinhThucVanChuyen;
                        cp.HinhThucVanChuyen[i].Gia       = tr.HinhThucVanChuyen[i].Gia;
                        cp.HinhThucVanChuyen[i].DonViTien = tr.HinhThucVanChuyen[i].DonViTien;
                    }
                }
            }
            return(companny);
        }
Beispiel #4
0
        public static string Confirm(string sid, string transCompanyId, string transTypeId, string validationCode, string contact)
        {
            int result = ConsumerDAO.CheckAvaliableSID(sid);

            if (result >= 1)
            {
                int madv = 0;
                if (int.TryParse(transCompanyId, out madv))
                {
                    int madh = 0;
                    int.TryParse(validationCode, out madh);
                    int soluong = GeneralPurchasingDAO.GetNumberCouponInOrder(madh);
                    if (soluong == 0)
                    {
                        return("Đơn hàng chưa được duyệt");
                    }
                    int transtype = 0;
                    int.TryParse(transTypeId, out transtype);
                    SERVICE_TRANS_DTO sv = GeneralPurchasingDAO.GetInfoServiceTrans(madv);

                    /*string bizAddress = "";
                     * if (ConfigurationManager.AppSettings.GetValues(transCompanyId)[0] != null)
                     * {
                     *  bizAddress = ConfigurationManager.AppSettings.GetValues(transCompanyId)[0];
                     * }
                     * else
                     * {
                     *  bizAddress = ConfigurationManager.AppSettings.GetValues("biz")[0];
                     * }*/
                    VanChuyen.FedexWebService1 proxy = new BizWebservice.VanChuyen.FedexWebService1();
                    proxy.Url = sv.LinkWebService;
                    string id = proxy.Authenticate(sv.UserName, sv.PassWord);
                    // proxy.Url = "http://thuongmainhommot.somee.com/Service/WebServiceVanChuyen.asmx";
                    // string id = proxy.Authenticate("demo","123");
                    string url = proxy.TransportGoods(id, validationCode, soluong, DateTime.Today.Date.AddDays(1), contact, transtype, sv.BizAddress);
                    // if (url.IndexOf("http://") >= 0 || url.IndexOf("https://") >= 0)
                    if (url.IndexOf(".aspx?") >= 0)
                    {
                        // string package = proxy.GetPackageInfo(id, url);
                        int result1 = GeneralPurchasingDAO.ConfirmOrder(madh, contact, sid);

                        /*  if (result1 != 1)
                         * {
                         *    proxy.CancelPackage(id, url);
                         * }*/
                    }
                    return(url);
                }
                else
                {
                    return("false");
                }
            }
            else
            {
                return("Invalid sid");
            }
        }
Beispiel #5
0
 public static int UpdateServiceTrans(SERVICE_TRANS_DTO service)
 {
     try
     {
         return(ServiceTransDAO.UpdateServiceTrans(service));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            int isLogIn;

            int.TryParse(Session["IsLogin"].ToString(), out isLogIn);
            if (isLogIn == 1)
            {
                string typeUser = Session["LoaiUser"].ToString();
                if (typeUser == "Admin")
                {
                    if (!IsPostBack)
                    {
                        string query = Request.QueryString["madv"];
                        if (query != null)
                        {
                            int madv;
                            int.TryParse(query, out madv);
                            hdfId.Value = madv.ToString();
                            SERVICE_TRANS_DTO service = ServiceTransBUS.GetServiceTransInfor(madv);
                            txtName.Text     = service.TenCongTy;
                            txtLink.Text     = service.LinkWebService;
                            txtWebsite.Text  = service.Website;
                            txtUserName.Text = service.UserName;
                            //txtPass.TextMode = TextBoxMode.SingleLine;
                            txtPass.Text = service.PassWord;
                            //  txtPass.AutoPostBack = false;
                            //  txtPass.TextMode = TextBoxMode.Password;
                            if (service.TinhTrang == 1)
                            {
                                DropDownList1.Items[0].Selected = true;
                            }
                            else
                            {
                                DropDownList1.Items[1].Selected = true;
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect("../Shared/Default.aspx");
                }
            }
            else
            {
                Response.Redirect("../Shared/Default.aspx");
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            SERVICE_TRANS_DTO service = new SERVICE_TRANS_DTO();

            service.TenCongTy      = txtName.Text;
            service.LinkWebService = txtLink.Text;
            service.UserName       = txtUserName.Text;
            service.PassWord       = txtPass.Text;
            service.Website        = txtWebsite.Text;
            service.BizAddress     = txtBizAddress.Text;
            try
            {
                /*  List<TransportType> transtypes = new List<TransportType>();
                 * for (int i = 0; i < grTransType.Rows.Count; i++)
                 * {
                 *    TransportType trans = new TransportType();
                 *    trans.MaHinhThucVanChuyen = i.ToString();
                 *    trans.TenHinhThucVanChuyen = grTransType.Rows[i].Cells[0].Text;
                 *    float price;
                 *    float.TryParse(((TextBox)grTransType.Rows[i].FindControl("txtPrice")).Text, out price);
                 *    trans.Gia = price;
                 *    trans.DonViTien = ((TextBox)grTransType.Rows[i].FindControl("txtMoney")).Text;
                 *    transtypes.Add(trans);
                 * }*/
                int result = ServiceTransBUS.InsertServiceTrans(service);
                if (result == 1)
                {
                    lbResult.ForeColor = Color.Green;
                    lbResult.Text      = "Đã thêm thành công";
                }
                else
                {
                    lbResult.ForeColor = Color.Red;
                    lbResult.Text      = "Lỗi hệ thống, vui lòng thử lại sau!";
                }
            }
            catch (Exception ex)
            {
                lbResult.ForeColor = Color.Red;
                lbResult.Text      = "Lỗi hệ thống, vui lòng thử lại sau!";
            }
        }
Beispiel #8
0
        private static void TransFerToListServiceTrans(List <SERVICE_TRANS_DTO> services, DataTable table)
        {
            int n = table.Rows.Count;

            for (int i = 0; i < n; i++)
            {
                DataRow           row = table.Rows[i];
                SERVICE_TRANS_DTO sv  = new SERVICE_TRANS_DTO();
                sv.MaDV           = int.Parse(row["MADV"].ToString());
                sv.TenCongTy      = row["TENCTY"].ToString();
                sv.LinkWebService = row["LINKWS"].ToString();
                sv.UserName       = row["USERNAME"].ToString();
                sv.PassWord       = row["PASS_WORD"].ToString();
                sv.TinhTrang      = int.Parse(row["TINHTRANG"].ToString());
                sv.Title          = "Cập nhật";
                sv.Website        = row["WEBSITE"].ToString();
                sv.BizAddress     = row["BIZADDRESS"].ToString();
                services.Add(sv);
            }
        }
Beispiel #9
0
        public static int InsertServiceTrans(SERVICE_TRANS_DTO service)
        {
            try
            {
                int madv = ServiceTransDAO.InsertServiceTrans(service);
                if (madv == -1)
                {
                    return(-1);
                }

                /*  foreach (TransportType type in types)
                 * {
                 *    type.Madv = madv;
                 *    ServiceTransDAO.InsertTransType(type);
                 * }*/
                return(1);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #10
0
        protected void btnPayment_Click(object sender, EventArgs e)
        {
            string ma = rdvc.SelectedValue;

            string[] arr  = ma.Split(new char[] { ',' });
            int      madv = 0;

            int.TryParse(arr[0], out madv);
            int type = 0;

            int.TryParse(arr[1], out type);
            string bank = rdbank.SelectedValue;

            string[] bankarr = bank.Split(new char[] { '+' });
            string   bankid  = bankarr[0];
            string   stk     = bankarr[1];

            /* tao don hang , va xoa gio hang */
            if (Session["Cart"] != null)
            {
                List <GioHang> carts = (List <GioHang>)Session["Cart"];
                if (carts.Count > 0)
                {
                    DON_HANG_DTO dh = new DON_HANG_DTO();
                    dh.DiaChiNhan  = txtAddress.Text;
                    dh.DonViTienTe = carts[0].TienTe;
                    dh.NgayGiao    = DateTime.Now;
                    dh.UserName    = Session["User"].ToString();
                    dh.TongTien    = 0;
                    foreach (GioHang cart in carts)
                    {
                        dh.TongTien += (cart.DonGia * cart.SoLuong);
                    }
                    int madh = 0;
                    madh       = DonHangBUS.InsetOrder(dh);
                    dh.ChiTiet = new List <CHI_TIET_DON_HANG_DTO>();
                    foreach (GioHang cart in carts)
                    {
                        CHI_TIET_DON_HANG_DTO ct = new CHI_TIET_DON_HANG_DTO();
                        ct.donGia    = cart.DonGia;
                        ct.donViTinh = cart.DonViTinh;
                        ct.maDonHang = madh;
                        ct.maSanPham = cart.MaSanPham;
                        ct.soLuong   = cart.SoLuong;
                        try
                        {
                            DonHangBUS.InsertCTOrder(ct);
                        }
                        catch (Exception ex)
                        {
                            continue;
                        }
                    }
                    /* thanh toan */
                    SERVICE_BANK_DTO     svbank = ServiceBankBUS.LayServiceBankTheoMaBank(bankid);
                    NganHang.KhachHangWS proxy1 = new BIZ.NganHang.KhachHangWS();
                    string sid    = proxy1.Authenticate(svbank.UserName, svbank.PassWord);
                    int    result = proxy1.TransferMoney(sid, txtId.Text, bankid, svbank.Stk, svbank.MaBank, dh.TongTien, "VND");
                    if (result == 1)
                    {
                        /* dang ky van chuyen */
                        SERVICE_TRANS_DTO          svtran = ServiceTransBUS.GetServiceTransInfor(madv);
                        VanChuyen.FedexWebService1 proxy2 = new BIZ.VanChuyen.FedexWebService1();
                        sid = proxy2.Authenticate(svtran.UserName, svtran.PassWord);
                        string url = proxy2.TransportGoods(sid, madh.ToString(), carts.Count, DateTime.Now.AddDays(1), txtAddress.Text, type, svtran.BizAddress);
                        if (url.IndexOf(".aspx?") >= 0 || url.IndexOf("http://") >= 0 || url.IndexOf("https://") >= 0)
                        {
                            PACKAGEINFO_DTO pac = new PACKAGEINFO_DTO();
                            pac.URL            = url;
                            pac.MaServiceTrans = svtran.MaDV;
                            pac.PackageInfo    = madh.ToString();
                            try
                            {
                                DonHangBUS.InsertPackage(pac, madh);
                                foreach (GioHang cart in carts)
                                {
                                    //CHI_TIET_DON_HANG_DTO ct = new CHI_TIET_DON_HANG_DTO();

                                    try
                                    {
                                        ProductBUS.UpdateSLProduct(cart.MaSanPham, cart.SoLuong);
                                    }
                                    catch (Exception ex)
                                    {
                                        continue;
                                    }
                                }
                                Session["Cart"]    = null;
                                lbresult.ForeColor = Color.Green;
                                lbresult.Text      = "Quá trình mua đã thành công";
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }
                        else
                        {
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Đã thanh toán nhưng đặt vận chuyển thất bại";
                        }
                    }
                    else
                    {
                        switch (result)
                        {
                        case 2:
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Tài khoản chuyển không đủ tiền";
                            break;

                        case 3:
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Tài khoản chuyển không tồn tại";
                            break;

                        case 4:
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Tài khoản nhận không tồn tại";
                            break;

                        case 5:
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Mã ngân hàng chuyển tiền/Mã ngân hàng nhận tiền không tồn tại ";
                            break;

                        case 6:
                            lbresult.ForeColor = Color.Red;
                            lbresult.Text      = "Lỗi khác";
                            break;
                        }
                    }
                }
            }
        }