コード例 #1
0
ファイル: API.cs プロジェクト: dtsonvt/IPC247
        public static void API_ERRORLOG(ERRORLOG log)
        {
            try
            {
                string str = "[" +
                             string.Format(@" {{""Key"":""IP"",""value"":""{0}"",""Type"":""string""}},
								{{""Key"":""UserName"",""value"":""{1}"",""Type"":""string""}},
								{{""Key"":""Form"",""value"":""{2}"",""Type"":""string""}},
								{{""Key"":""Event"",""value"":""{3}"",""Type"":""string""}},
								{{""Key"":""ErrorDescription"",""value"":""{4}"",""Type"":""Base64""}}"
                                           , log.IP                                                               //0
                                           , Form_Main.user.Username                                              //1
                                           , log.Form                                                             //2
                                           , log.Event                                                            //3
                                           , Convert.ToBase64String(Encoding.UTF8.GetBytes(log.ErrorDescription)) //4
                                           ) + "]";                                                               //6
                //  JObject json = JObject.Parse(str);
                var    json  = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_Insert_ERROR_LOG", Param = str });
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_SaveQuote";
                json = API.API_POS(sLink, json);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
            }
            catch
            {
            }
        }
コード例 #2
0
        private void SaveInfo()
        {
            try
            {
                InfoIPC ipc = new InfoIPC();
                ipc.TenCongTy = txtTenCty.Text;
                ipc.NguoiGui  = txtNguoiGui.Text;
                ipc.Mobile    = txtMobile.Text;
                ipc.Email     = txtEmail.Text;
                ipc.DiaChi    = txtDiaChi.Text;
                var    jsonsave   = new JavaScriptSerializer().Serialize(ipc);
                string base64info = Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonsave.ToString()));
                string str        = "[" + string.Format(@"{{""Key"":""Key"",""value"":""{0}"",""Type"":""string""}},{{""Key"":""Value"",""value"":""{1}"",""Type"":""string""}},{{""Key"":""UserID"",""value"":""{2}"",""Type"":""string""}}", "Info", base64info, Form_Main.user.Username) + "]";

                var    json  = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_UpdateInfoMaster", Param = str });
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_SaveQuote";
                json = API.API_POS(sLink, json);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     Message       = jsondataChild.First.GetValue("Message").Value;

                XtraMessageBox.Show(Message, "Thông Báo", System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_MasterData", "SaveInfo()", ex.ToString()));
                XtraMessageBox.Show("Cập Nhật Thông Tin Không Thành Công", "Thông Báo", System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
ファイル: Form_DoanhNghiep.cs プロジェクト: dtsonvt/IPC247
        void SaveInfo()
        {
            try
            {
                bool flag_edit = false;
                if (string.IsNullOrEmpty(txtTenCongTy.Text) || txtTenCongTy.Text.Length < 4)
                {
                    dxErrorProvider1.SetError(txtTenCongTy, "Tên công ty ít nhất 4 ký tự");
                    flag_edit = true;
                }
                else
                {
                    dxErrorProvider1.SetError(txtTenCongTy, null);
                }
                if (flag_edit)
                {
                    XtraMessageBox.Show("Vui lòng bổ sung những thông tin còn trống", "Thông Báo");
                    return;
                }

                string str = "[" +
                             string.Format(@" 
                                {{""Key"":""ID"",""value"":""{0}"",""Type"":""string""}},
                                {{""Key"":""CompanyName"",""value"":""{1}"",""Type"":""Base64""}},
                                {{""Key"":""Description"",""value"":""{2}"",""Type"":""Base64""}},
                                {{""Key"":""Address"",""value"":""{3}"",""Type"":""string""}},
                                {{""Key"":""Status"",""value"":""{4}"",""Type"":""string""}},
                                {{""Key"":""User"",""value"":""{5}"",""Type"":""string""}}  ",
                                           IDCompany                                                           //0
                                           , Convert.ToBase64String(Encoding.UTF8.GetBytes(txtTenCongTy.Text)) //1
                                           , Convert.ToBase64String(Encoding.UTF8.GetBytes(txtMoTa.Text))      //2
                                           , txtDiaChi.Text                                                    //3
                                           , cbbTrangThai.EditValue.ToString()                                 //4
                                           , Form_Main.user.Username                                           //5
                                           ) + "]";
                //  JObject json = JObject.Parse(str);
                var    json  = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_Company_Insert", Param = str });
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_SaveQuote";
                json = API.API_POS(sLink, json);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     Message       = jsondataChild.First.GetValue("Message").Value;

                if (Result == 1)//Login thành công
                {
                    //XtraMessageBox.Show(Message, "Thông Báo");
                    sp_Get_Company();
                }
                else
                {
                    XtraMessageBox.Show("Lưu Thông Tin Không Thành Công", "Thông Báo");
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_DoanhNghiep", "SaveInfo()", ex.ToString()));
            }
        }
コード例 #4
0
        private void UpdateData()
        {
            try
            {
                Product product = new Product();
                product.Id          = int.Parse(ID == "" ? "0" : ID);
                product.ProductCode = txtMaSP.Text;
                product.ProductName = txtTenSP.Text;
                product.Description = txtMoTa.Text;
                product.Price       = decimal.Parse(txtDonGia.EditValue.ToString());
                product.CostPrice   = decimal.Parse(txtGiaNhap.EditValue.ToString());
                //string sql_Exect = string.Format("Exec sp_Product_Update @ID ={0},@ProductCode=N'{1}',@ProductName=N'{2}',@Description=N'{3}'," +
                //    "@Price={4},@UserID='{5}',@CostPrice={6}", product.Id, product.ProductCode, product.ProductName, product.Description, product.Price, Form_Main.user.Username,product.CostPrice);

                //string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                string str = "[" +
                             string.Format(@" {{""Key"":""ID"",""value"":""{0}"",""Type"":""string""}},
{{""Key"":""ProductCode"",""value"":""{1}"",""Type"":""string""}},
{{""Key"":""ProductName"",""value"":""{2}"",""Type"":""string""}},
{{""Key"":""Description"",""value"":""{3}"",""Type"":""string""}},
{{""Key"":""Price"",""value"":""{4}"",""Type"":""string""}},
{{""Key"":""UserID"",""value"":""{5}"",""Type"":""string""}},
{{""Key"":""CostPrice"",""value"":""{6}"",""Type"":""string""}}"
                                           , product.Id                //0
                                           , product.ProductCode       //1
                                           , product.ProductName       //2
                                           , product.Description       //3
                                           , product.Price             //4
                                           , Form_Main.user.Username   //5
                                           , product.CostPrice) + "]"; //6
                //  JObject json = JObject.Parse(str);
                var    json  = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_Product_Update", Param = str });
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_SaveQuote";
                json = API.API_POS(sLink, json);
                dynamic jsondata = JObject.Parse(json);
                //	var json = API.API_GET(sLink);
                //   dynamic jsondata = JObject.Parse(json);
                var    jsondataChild = jsondata.GetValue("Data");
                string result        = jsondataChild.First.GetValue("Result").Value.ToString();
                if (result != null && result == "1")
                {
                    ID = jsondataChild.First.GetValue("ID").Value.ToString();
                    LoadInfoProduct();
                }
                else
                {
                    string Message = jsondataChild.First.GetValue("Message").Value.ToString();
                    XtraMessageBox.Show(Message, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Product", "UpdateData()", ex.ToString()));
            }
        }
コード例 #5
0
        public void XuLyDangNhap(string username, string password)
        {
            try
            {
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_Login";
                var    json  = new JavaScriptSerializer().Serialize(new { UserName = username, Password = password });
                json = API.API_POS(sLink, json);
                if (json != null)
                {
                    dynamic jsondata      = JObject.Parse(json);
                    var     jsondataChild = jsondata.GetValue("Data");
                    var     Result        = jsondataChild.First.GetValue("Result").Value;
                    var     Message       = jsondataChild.First.GetValue("Message").Value;

                    if (Result == 1)                    //Login thành công
                    {
                        Form_Main.Flag_Login    = true;
                        Form_Main.user.Username = username;
                        Form_Main.user.Name     = Message;
                        Form_Main.user.Email    = jsondataChild.First.GetValue("Email").Value;
                        Form_Main.user.Phone    = jsondataChild.First.GetValue("Phone").Value;
                        Form_Main.user.ChucNang = jsondataChild.First.GetValue("ChucNang").Value;
                        this.Close();
                    }
                    else
                    {
                        XtraMessageBox.Show(Message, "Thông Báo");
                        this.Show();
                    }
                }
                else
                {
                    XtraMessageBox.Show("Không kết nối được tới Server! vui lòng thử lại sau", "Thông Báo");
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Login", "XuLyDangNhap()", ex.ToString()));
            }
        }
コード例 #6
0
        /// <summary>
        /// ImageIndex : option 1: ImageLeft/ 2: ImageRight
        /// </summary>
        /// <param name="ImageIndex"></param>
        private void SaveImage(string ImageIndex)
        {
            try
            {
                Image img;
                if (ImageIndex == "ImageLeft")
                {
                    img = ptbHinhTrai.Image;
                }
                else
                {
                    img = ptbHinhPhai.Image;
                }
                string base64 = "";
                if (img != null)
                {
                    base64 = Convert.ToBase64String(ImageToByteArray(img));
                }
                string str = "[" + string.Format(@"{{""Key"":""Key"",""value"":""{0}"",""Type"":""string""}},{{""Key"":""Value"",""value"":""{1}"",""Type"":""string""}},{{""Key"":""UserID"",""value"":""{2}"",""Type"":""string""}}", ImageIndex, base64, Form_Main.user.Username) + "]";

                var    json  = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_UpdateInfoMaster", Param = str });
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_SaveQuote";
                json = API.API_POS(sLink, json);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     Message       = jsondataChild.First.GetValue("Message").Value;

                // XtraMessageBox.Show(Message, "Thông Báo", System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_MasterData", "SaveImage()", ex.ToString()));
                XtraMessageBox.Show("Cập Nhật Thông Tin Không Thành Công", "Thông Báo", System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #7
0
 private void Saveinfo()
 {
     try
     {
         #region Check Validate
         bool flag_edit = false;
         // check tên dự án
         if (string.IsNullOrEmpty(txtNoiDung.Text) || txtNoiDung.Text.Length < 3)
         {
             dxErrorProvider1.SetError(txtNoiDung, "Phần Mồ Tả ít nhất 3 ký tự");
             flag_edit = true;
         }
         else
         {
             dxErrorProvider1.SetError(txtNoiDung, null);
         }
         // check trạng thái dự án
         if (string.IsNullOrEmpty(txtTrangThai.Text) || txtTrangThai.Text.Length < 3)
         {
             dxErrorProvider1.SetError(txtTrangThai, "Phần Trạng thái ít nhất 3 ký tự");
             flag_edit = true;
         }
         else
         {
             dxErrorProvider1.SetError(txtTrangThai, null);
         }
         // check deadline
         if (txtDeadline.DateTime < DateTime.Now)
         {
             dxErrorProvider1.SetError(txtDeadline, "Thời gian DEADLINE không được nhỏ hơn thời gian hiện tại");
             flag_edit = true;
         }
         else
         {
             dxErrorProvider1.SetError(txtDeadline, null);
         }
         if (flag_edit)
         {
             XtraMessageBox.Show("Vui lòng bổ sung những thông tin còn trống", "Thông Báo");
             return;
         }
         #endregion Check Validate
         #region Lưu thông tin
         string str = "[" +
                      string.Format(@" 
                         {{""Key"":""Id_Enquiry"",""value"":""{0}"",""Type"":""string""}},
                         {{""Key"":""ID"",""value"":""{1}"",""Type"":""string""}},
                         {{""Key"":""Description"",""value"":""{2}"",""Type"":""string""}},
                         {{""Key"":""Curator"",""value"":""{3}"",""Type"":""string""}},
                         {{""Key"":""Status"",""value"":""{4}"",""Type"":""string""}},
                         {{""Key"":""User"",""value"":""{5}"",""Type"":""string""}},
                         {{""Key"":""DeadLine"",""value"":""{6}"",""Type"":""Base64""}} ",
                                    en.ID_Enquiry                                                                                          //0
                                    , IDDetail                                                                                             //1
                                    , txtNoiDung.Text                                                                                      //2
                                    , txtPhuTrach.EditValue.ToString()                                                                     //3
                                    , txtTrangThai.EditValue.ToString()                                                                    //4
                                    , Form_Main.user.Username                                                                              //5
                                    , Convert.ToBase64String(Encoding.UTF8.GetBytes(txtDeadline.DateTime.ToString("dd/MM/yyyy HH:mm:ss"))) // 6
                                    ) + "]";
         //  JObject json = JObject.Parse(str);
         var    json  = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_Save_info_EnquiryDetails", Param = str });
         string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_SaveQuote";
         json = API.API_POS(sLink, json);
         dynamic jsondata      = JObject.Parse(json);
         var     jsondataChild = jsondata.GetValue("Data");
         var     Result        = jsondataChild.First.GetValue("Result").Value;
         var     Message       = jsondataChild.First.GetValue("Message").Value;
         if (Result == 1)//Login thành công
         {
             LoadEnquiryDetial(en.ID_Enquiry);
         }
         else
         {
             XtraMessageBox.Show("Lưu Thông Tin Không Thành Công", "Thông Báo");
         }
         #endregion Lưu thông tin
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Enquiry", "Saveinfo()", ex.ToString()));
     }
 }
コード例 #8
0
ファイル: Form_Add_Enquiry.cs プロジェクト: dtsonvt/IPC247
        private void Saveinfo()
        {
            try
            {
                #region Check Validate
                bool flag_edit = false;
                // check tên công ty
                if (string.IsNullOrEmpty(txtCongty.Text) || txtCongty.Text.Length < 3)
                {
                    dxErrorProvider1.SetError(txtCongty, "Tên công ty ít nhất 3 ký tự");
                    flag_edit = true;
                }
                else
                {
                    dxErrorProvider1.SetError(txtCongty, null);
                }
                // check tên khách hàng
                if (string.IsNullOrEmpty(txtKhachHang.Text) || txtKhachHang.Text.Length < 3)
                {
                    dxErrorProvider1.SetError(txtKhachHang, "Tên công ty ít nhất 3 ký tự");
                    flag_edit = true;
                }
                else
                {
                    dxErrorProvider1.SetError(txtKhachHang, null);
                }
                // check tên dự án
                if (string.IsNullOrEmpty(txtEnquiry.Text) || txtEnquiry.Text.Length < 3)
                {
                    dxErrorProvider1.SetError(txtEnquiry, "Tên công ty ít nhất 3 ký tự");
                    flag_edit = true;
                }
                else
                {
                    dxErrorProvider1.SetError(txtEnquiry, null);
                }

                if (flag_edit)
                {
                    XtraMessageBox.Show("Vui lòng bổ sung những thông tin còn trống", "Thông Báo");
                    return;
                }
                #endregion Check Validate
                #region Lưu thông tin header
                string str = "[" +
                             string.Format(@" 
                                {{""Key"":""IDRequest"",""value"":""{0}"",""Type"":""string""}},
                                {{""Key"":""IDCardCode"",""value"":""{1}"",""Type"":""string""}},
                                {{""Key"":""Company"",""value"":""{2}"",""Type"":""string""}},
                                {{""Key"":""CompanyName"",""value"":""{3}"",""Type"":""string""}},
                                {{""Key"":""Description"",""value"":""{4}"",""Type"":""string""}},
                                {{""Key"":""SDT"",""value"":""{5}"",""Type"":""string""}},
                                {{""Key"":""Email"",""value"":""{6}"",""Type"":""string""}},
                                {{""Key"":""User"",""value"":""{7}"",""Type"":""string""}} ,
                                {{""Key"":""ID_Enquiry"",""value"":""{8}"",""Type"":""string""}} ,
                                {{""Key"":""EnquiryName"",""value"":""{9}"",""Type"":""string""}} ,
                                {{""Key"":""Curator"",""value"":""{10}"",""Type"":""string""}},
                                {{""Key"":""CardName"",""value"":""{11}"",""Type"":""string""}}",
                                           en.ID_Request             //0
                                           , cus.ID                  //1
                                           , com.ID                  //2
                                           , txtCongty.Text          //3
                                           , txtMoTa.Text            //4
                                           , txtSDT.Text             //5
                                           , txtEmail.Text           //6
                                           , Form_Main.user.Username //7
                                           , en.ID_Enquiry           //8
                                           , txtEnquiry.Text         //9
                                           , txtPhuTrach.EditValue   //10
                                           , txtKhachHang.Text       //11
                                           ) + "]";
                //  JObject json = JObject.Parse(str);
                var    json  = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_Enquiry_Insert", Param = str });
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_SaveQuote";
                json = API.API_POS(sLink, json);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     ID_Enquiry    = jsondataChild.First.GetValue("ID_Enquiry").Value;
                var     Company       = jsondataChild.First.GetValue("Company").Value;
                var     IDCardCode    = jsondataChild.First.GetValue("IDCardCode").Value;
                if (Result == 1)//Login thành công
                {
                    if (ID_Enquiry != "0")
                    {
                        en.ID_Enquiry  = ID_Enquiry;
                        en.CardCode    = IDCardCode;
                        en.CompanyCode = Company;
                        PushInfo();
                        this.Close();
                    }
                }
                else
                {
                    XtraMessageBox.Show("Lưu Thông Tin Không Thành Công", "Thông Báo");
                }

                #endregion lưu thông tin header
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Add_Enquiry", "Saveinfo()", ex.ToString()));
            }
        }
コード例 #9
0
ファイル: Form_Account.cs プロジェクト: dtsonvt/IPC247
        private void  LuuThongTin()
        {
            bool flag_edit = false;

            if (txtMatKhau.Text != txtNhapLaiMatKhau.Text)
            {
                dxErrorProvider1.SetError(txtMatKhau, "Mật Khẩu Nhập Lại Không Khớp");
                dxErrorProvider1.SetError(txtNhapLaiMatKhau, "Mật Khẩu Nhập Lại Không Khớp");
                flag_edit = true;
            }
            else
            {
                dxErrorProvider1.SetError(txtMatKhau, null);
                dxErrorProvider1.SetError(txtNhapLaiMatKhau, null);
            }
            if (string.IsNullOrEmpty(txtUserName.Text) || txtUserName.Text.Length < 4)
            {
                dxErrorProvider1.SetError(txtUserName, "Tên đăng nhập ít nhất 4 ký tự");
                flag_edit = true;
            }
            else
            {
                dxErrorProvider1.SetError(txtUserName, null);
            }
            if (string.IsNullOrEmpty(cbbNhomQuyen.Text) || cbbNhomQuyen.Text.Length == 0)
            {
                dxErrorProvider1.SetError(cbbNhomQuyen, "Bạn cần phải thiết lập nhóm quyền cho tài khoản");
                flag_edit = true;
            }
            else
            {
                dxErrorProvider1.SetError(cbbNhomQuyen, null);
            }
            if (string.IsNullOrEmpty(txtTenUser.Text) || txtTenUser.Text.Length < 3)
            {
                dxErrorProvider1.SetError(txtTenUser, "Tên Người Dùng Phải có ít nhất 2 Ký tự");
                flag_edit = true;
            }
            else
            {
                dxErrorProvider1.SetError(txtTenUser, null);
            }
            if (flag_edit)
            {
                XtraMessageBox.Show("Vui lòng bổ sung những thông tin còn trống", "Thông Báo");
                return;
            }
            string MatKhau = txtMatKhau.Text;

            if (MatKhau == MatKhauOld)
            {
                MatKhau = "";
            }
            else
            {
                MatKhau = EncryptPass(txtNhapLaiMatKhau.Text);
            }
            try
            {
                string str = "[" +
                             string.Format(@" {{""Key"":""ID"",""value"":""{0}"",""Type"":""string""}},{{""Key"":""UserName"",""value"":""{1}"",""Type"":""string""}},
{{""Key"":""Password"",""value"":""{2}"",""Type"":""string""}},{{""Key"":""Name"",""value"":""{3}"",""Type"":""string""}},{{""Key"":""RoleGroup"",""value"":""{4}"",""Type"":""string""}},
{{""Key"":""Address"",""value"":""{5}"",""Type"":""string""}},{{""Key"":""Email"",""value"":""{6}"",""Type"":""string""}},{{""Key"":""Phone"",""value"":""{7}"",""Type"":""string""}},{{""Key"":""Status"",""value"":""{8}"",""Type"":""string""}},
{{""Key"":""IsLogin"",""value"":""{9}"",""Type"":""string""}},{{""Key"":""User"",""value"":""{10}"",""Type"":""string""}}"
                                           , ID                                       //0
                                           , txtUserName.Text                         //1
                                           , MatKhau                                  //2
                                           , txtTenUser.Text                          //3
                                           , cbbNhomQuyen.EditValue                   //4
                                           , txtDiaChi.Text                           // 5
                                           , txtEmail.Text                            //6
                                           , txtSDT.Text                              //7
                                           , txtTrangThai.Checked?"1":"0"             //8
                                           , cbbTrangThaiDangNhap.Checked ? "1" : "0" //9                           ,                                       // , xEle.ToString()
                                           , Form_Main.user.Username) + "]";          //10
                                                                                      //  JObject json = JObject.Parse(str);
                var    json  = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_Account_Insert", Param = str });
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_SaveQuote";
                json = API.API_POS(sLink, json);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     Message       = jsondataChild.First.GetValue("Message").Value;

                if (Result == 1)//Login thành công
                {
                    XtraMessageBox.Show(Message, "Thông Báo");
                    LoadForm();
                }
                else
                {
                    XtraMessageBox.Show("Cập Nhật Thông Tin Không Thành Công", "Thông Báo");
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_NhomQuyen", "LuuThongTin()", ex.ToString()));
            }
        }
コード例 #10
0
        // Lưu báo Giá
        private void SaveQuote()
        {
            try
            {
                if (lst.Count == 0)
                {
                    XtraMessageBox.Show("Danh sách sản phẩm chưa có sản phẩm nào!", "Thông Báo");
                    return;
                }
                if (lst.Exists(o => o.Status == 0))
                {
                    XtraMessageBox.Show("Trong báo giá có ít nhất một sản phẩm không còn bán!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                var xEle = new XElement("line",
                                        from emp in lst
                                        select new XElement("item",
                                                            new XAttribute("ID", emp.ID),
                                                            new XAttribute("MaSP", emp.MaSP),
                                                            new XAttribute("TenHang", emp.TenHang),
                                                            new XAttribute("MoTa", emp.MoTaHangHoa),
                                                            new XAttribute("DonGia", emp.DonGia),
                                                            new XAttribute("Quantity", emp.SoLuong),
                                                            new XAttribute("ChietKhau", emp.ChietKhau),
                                                            new XAttribute("ThanhTien", emp.ThanhTien),
                                                            new XAttribute("Profit", emp.Profit),
                                                            new XAttribute("CostPrice", emp.CostPrice),
                                                            new XAttribute("IsGroup", emp.IsGroup)
                                                            ));

                string A = xEle.ToString();
                if (ID_Header == "")
                {
                    ID_Header = "0";
                }
                //   return Request.CreateResponse(HttpStatusCode.OK, new { Success = true, Data = ConvertDataTableToListObject(dt) });
                // };
                string str = "[" +
                             string.Format(@" {{""Key"":""ID"",""value"":""{0}"",""Type"":""string""}},{{""Key"":""SoBaoGia"",""value"":""{1}"",""Type"":""string""}},
{{""Key"":""ToKhachHang"",""value"":""{2}"",""Type"":""string""}},{{""Key"":""NguoiNhan"",""value"":""{3}"",""Type"":""string""}},{{""Key"":""Mobile_NguoiNhan"",""value"":""{4}"",""Type"":""string""}},
{{""Key"":""Tel_NguoiNhan"",""value"":""{5}"",""Type"":""string""}},{{""Key"":""NgayBaoGia"",""value"":""{6}"",""Type"":""string""}},{{""Key"":""Email_NguoiNhan"",""value"":""{7}"",""Type"":""string""}},{{""Key"":""VAT"",""value"":""{8}"",""Type"":""string""}},
{{""Key"":""XMLSanPham"",""value"":""{9}"",""Type"":""Base64""}},{{""Key"":""TongTien"",""value"":""{10}"",""Type"":""string""}},{{""Key"":""UserID"",""value"":""{11}"",""Type"":""string""}},{{""Key"":""DiaChi"",""value"":""{12}"",""Type"":""string""}},{{""Key"":""DieuKhoan"",""value"":""{13}"",""Type"":""string""}},{{""Key"":""ID_Enquiry"",""value"":""{14}"",""Type"":""string""}},{{""Key"":""IDCardCode"",""value"":""{15}"",""Type"":""string""}},{{""Key"":""Company"",""value"":""{16}"",""Type"":""string""}} "
                                           , ID_Header                                                       //0
                                           , txtTenBaoGia.Text                                               //1
                                           , txtToKH.Text                                                    //2
                                           , txtTenKH.Text                                                   //3
                                           , txtSDT.Text                                                     //4
                                           , txtTel.Text                                                     //5
                                           , NgayBaoGia.ToString("dd/MM/yyyy")                               // 6
                                           , txtEmail.Text                                                   //7
                                           , txtVAT.EditValue.ToString()                                     //8
                                           , Convert.ToBase64String(Encoding.UTF8.GetBytes(xEle.ToString())) //9
                                           , lst.Sum(o => o.ThanhTien).ToString()                            //10
                                           , Form_Main.user.Username                                         //11
                                           , txtDiaChi.Text                                                  //12
                                           , txtDieuKhoan.Text                                               //13
                                           , en.ID_Enquiry                                                   //14
                                           , cus.ID                                                          //15
                                           , com.ID                                                          //16
                                           ) + "]";
                //  JObject json = JObject.Parse(str);
                var    json  = new JavaScriptSerializer().Serialize(new { StoreProcedure = "sp_SaveQuote", Param = str });
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_SaveQuote";
                json = API.API_POS(sLink, json);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     Message       = jsondataChild.First.GetValue("Message").Value;
                cus.ID = jsondataChild.First.GetValue("IDCardCode").Value.ToString();
                com.ID = jsondataChild.First.GetValue("IDCompany").Value.ToString();
                if (Result == 1)//Login thành công
                {
                    XtraMessageBox.Show(Message, "Thông Báo");
                }
                else
                {
                    XtraMessageBox.Show("Tạo Báo Giá Không Thành Công", "Thông Báo");
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Quote", "SaveQuote()", ex.ToString()));
            }
        }
コード例 #11
0
        private void button2_Click(object sender, EventArgs e)
        {
            btnImport.Enabled = false;
            SplashScreenManager.ShowDefaultWaitForm("Vui Lòng Chờ...", "Đang thực hiện thao tác...");
            string filename = txtLinkFile.Text;

            if (filename == "")
            {
                XtraMessageBox.Show("Vui Lòng Chọn File để IMPORT", "Thông Báo");
                return;
            }
            try
            {
                DataTable       dt = new DataTable();
                string          FRConnectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 8.0", filename);
                OleDbConnection connection         = new OleDbConnection();
                connection.ConnectionString = FRConnectionString;
                //OleDbCommand cmd = new OleDbCommand("Select '" + DateTime.Today.ToShortDateString() + "',* from [Sheet1$]", connection);
                OleDbCommand cmd = new OleDbCommand("Select * from [Sheet1$]", connection);
                connection.Open();
                // OleDbDataReader dr = cmd.ExecuteReader();
                OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
                adapter.Fill(dt);
                List <Product> lstnew = new List <Product>();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Product ob = new Product();
                    ob.ProductCode = dt.Rows[i]["ProductCode"].ToString().Replace("\"", "''");
                    if (string.IsNullOrEmpty(ob.ProductCode))
                    {
                        continue;
                    }
                    ob.ProductName = dt.Rows[i]["ProductName"].ToString().Replace("\"", "''");
                    ob.Description = dt.Rows[i]["Description"].ToString().Replace("\"", "''");
                    ob.CostPrice   = decimal.Parse(dt.Rows[i]["CostPrice"].ToString());
                    ob.Price       = decimal.Parse(dt.Rows[i]["Price"].ToString());
                    ob.UserID      = Form_Main.user.Username;
                    lstnew.Add(ob);
                }
                var json = JsonConvert.SerializeObject(lstnew);


                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_ImportProduct";
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                serializer.MaxJsonLength = Int32.MaxValue;

                json = serializer.Serialize(new { UserName = Form_Main.user.Username, Data = json });

                var     jsonReturn    = API.API_POS(sLink, json);
                dynamic jsondata      = JObject.Parse(jsonReturn);
                var     jsondataChild = jsondata.GetValue("Data");
                //var Result = jsondataChild.First.GetValue("Result").Value;
                //var Message = jsondataChild.First.GetValue("Message").Value;
                LoadInfoProduct();
                btnImport.Enabled = false;
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Product", "Imort Dữ Liệu()", ex.ToString()));

                btnImport.Enabled = true;
                if (XtraMessageBox.Show(
                        "Máy bạn chưa hỗ trợ xử lý excel, Bấm 'YES' để tải file setup hỗ trợ", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information
                        ) == DialogResult.Yes)
                {
                    try
                    {
                        System.Diagnostics.Process.Start("chrome.exe", Form_Main.URL_API + "/Uploads/Tmp/template/AccessDatabaseEngine.exe");
                    }
                    catch
                    {
                        System.Diagnostics.Process.Start(Form_Main.URL_API + "/Uploads/Tmp/template/AccessDatabaseEngine.exe");
                        throw;
                    }
                }
            }
            SplashScreenManager.CloseDefaultWaitForm();
        }