Ejemplo n.º 1
0
    protected void btnTrail_Click(object sender, EventArgs e)
    {
        try
        {
            string FilePath = "", ConStr = "";

            if (FileUpload1.HasFile)
            {
                FilePath = Server.MapPath("~/Document/" + FileUpload1.PostedFile.FileName);
                string Extension = Path.GetExtension(FileUpload1.PostedFile.FileName);
                FileUpload1.SaveAs(FilePath);

                ImportDataFromExcel(FilePath, Extension, ConStr, "Yes");

                //  Bind Grid
                BindGrid();
            }
            else
            {
                WebMsgBox.Show("Plz Select the excel file first...!!", this.Page);
                FileUpload1.Focus();
                return;
            }
        }
        catch (Exception Ex)
        {
            ExceptionLogging.SendErrorToText(Ex);
        }
    }
    private bool CheckFileUpload()
    {
        string Extension, Filename;

        Extension = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);


        if (FileUpload1.HasFile == false)
        {
            ShowMsg("Please select a file");
            FileUpload1.Focus();
            return(false);
        }

        if (FileUpload1.PostedFile.ContentLength > 100000)
        {
            ShowMsg("File size too big");
            FileUpload1.Focus();
            return(false);
        }

        if (Extension == ".jpg" || Extension == ".jpeg" || Extension == ".gif" || Extension == ".png")
        {
            Filename = txtStudID.Text + Extension;

            FileUpload1.PostedFile.SaveAs(Server.MapPath("UserImage\\") + Filename);
            return(true);
        }


        ShowMsg("Incorrect file type");
        FileUpload1.Focus();
        return(false);
    }
Ejemplo n.º 3
0
    private bool CheckFileUpload()
    {
        string Extension, Filename;

        Extension = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);


        if (FileUpload1.HasFile == false)
        {
            ShowMsg("Please select a file");
            FileUpload1.Focus();
            return(false);
        }

        if (FileUpload1.PostedFile.ContentLength > 7000000)
        {
            ShowMsg("File size too big");
            FileUpload1.Focus();
            return(false);
        }

        if (Extension == ".doc" || Extension == ".docx" || Extension == ".pdf" || Extension == ".txt")
        {
            Filename = txtTutorialID.Text + Extension;

            FileUpload1.PostedFile.SaveAs(Server.MapPath("Tutorials\\") + Filename);
            return(true);
        }


        ShowMsg("Incorrect file type");
        FileUpload1.Focus();
        return(false);
    }
        public void subir()
        {
            if (Gv_Producto.Rows.Count < 1)
            {
                String mensajeScriptnm = @"<script type='text/javascript'>
                       swal({
                title: ""Seleccione Producto Txt"",
                icon: ""warning"",
                dangerMode: false,
            })
                  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScriptnm, false);
                FileUpload1.Focus();
                return;
            }
            Int32 IdUsuario = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"]);

            DataTable DtLis = new DataTable();

            DtLis.Columns.Add("IdProductoTxt", typeof(string));
            DtLis.Columns.Add("NombrePro", typeof(string));
            DtLis.Columns.Add("Precio", typeof(String));
            DtLis.Columns.Add("StockDisponible", typeof(Int32));

            Int32 IdTipoUsuario = 0;

            foreach (GridViewRow row in Gv_Producto.Rows)
            {
                DataRow drog = DtLis.NewRow();

                drog["IdProductoTxt"]   = Convert.ToString(row.Cells[0].Text.ToString());
                drog["NombrePro"]       = row.Cells[1].Text.ToString();
                drog["Precio"]          = Convert.ToString(row.Cells[2].Text.ToString());
                drog["StockDisponible"] = Convert.ToInt32(row.Cells[3].Text.ToString());
                IdTipoUsuario           = Convert.ToInt32(row.Cells[4].Text.ToString());
                DtLis.Rows.Add(drog);
            }
            String Msj = "";

            Msj = obj.SubirProductoPrecioTipoCliente(IdTipoUsuario, IdUsuario, DtLis);

            string menssajeScript = "<script type='text/javascript'>"
                                    + " swal({" +
                                    "title: '" + "" + Msj.ToString() + "'," +
                                    " icon: 'success'," +
                                    "  dangerMode: false," +
                                    "   })  </script>";

            ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
            DataTable dt = new DataTable();

            Gv_Producto.DataSource = dt;
            Gv_Producto.DataBind();
            LblTotal.Text = "";
            listar();
            PanelSubirNuevo.Visible = false;
            PanelListar.Visible     = true;
        }
Ejemplo n.º 5
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        try
        {
            DT = new DataTable();
            DT = FU.GetTransDetails(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), Session["MID"].ToString());
            if (DT.Rows.Count > 0)
            {
                RefNumber        = BD.GetMaxRefid(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), "REFID");
                ViewState["RID"] = (Convert.ToInt32(RefNumber) + 1).ToString();
                SetNo            = BD.GetSetNo(Session["EntryDate"].ToString(), "DaySetNo", Session["BRCD"].ToString()).ToString();

                if (Convert.ToDouble(SetNo.ToString()) > 0)
                {
                    //  Insert All Transaction Into M-Table
                    Result = FU.Authorized(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), Session["MID"].ToString(), SetNo.ToString(), ViewState["RID"].ToString(), "File Uploading");

                    //  Insert one by one transaction into avs_LnTrx Table
                    if (Result > 0)
                    {
                        DT = new DataTable();
                        DT = FU.GetLoanTrans(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), Session["MID"].ToString());
                        for (int i = 0; i < DT.Rows.Count; i++)
                        {
                            Result = FU.LoanTrx(DT.Rows[i]["BrCd"].ToString(), DT.Rows[i]["LoanGlCode"].ToString(), DT.Rows[i]["SubGlCode"].ToString(), DT.Rows[i]["AccountNo"].ToString(), DT.Rows[i]["HeadDesc"].ToString(), DT.Rows[i]["TrxType"].ToString(),
                                                DT.Rows[i]["Activity"].ToString(), DT.Rows[i]["ScrollNo"].ToString(), DT.Rows[i]["Narration"].ToString(), DT.Rows[i]["Amount"].ToString(), SetNo, "1003", DT.Rows[i]["MID"].ToString(), "0", DT.Rows[i]["EntryDate"].ToString(), ViewState["RID"].ToString());

                            if (Result > 0 && DT.Rows[i]["HeadDesc"].ToString() == "2" && DT.Rows[i]["TrxType"].ToString() == "2")
                            {
                                string IntApp = FU.GetIntApp(DT.Rows[i]["BrCd"].ToString(), DT.Rows[i]["LoanGlCode"].ToString());
                                if (Convert.ToDouble(IntApp.ToString()) == 1)
                                {
                                    Result = FU.UpdateLastIntDate(DT.Rows[i]["BrCd"].ToString(), DT.Rows[i]["LoanGlCode"].ToString(), DT.Rows[i]["AccountNo"].ToString(), DT.Rows[i]["EntryDate"].ToString(), DT.Rows[i]["MID"].ToString());
                                }
                            }
                        }

                        ClearAllData();
                        WebMsgBox.Show("File uploaded successfully with setno : " + Convert.ToInt32(SetNo), this.Page);
                        return;
                    }
                }
            }
            else
            {
                FileUpload1.Focus();
                WebMsgBox.Show("Please execute trail first...!!", this.Page);
                return;
            }
        }
        catch (Exception Ex)
        {
            ExceptionLogging.SendErrorToText(Ex);
        }
    }
Ejemplo n.º 6
0
        public void subir()
        {
            if (GV_RUTA.Rows.Count < 1)
            {
                String mensajeScriptnm = @"<script type='text/javascript'>
                       swal({
                title: ""Seleccione Ruta Txt"",
                icon: ""warning"",
                dangerMode: false,
            })
                  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScriptnm, false);
                FileUpload1.Focus();
                return;
            }

            Int32 IdUsuario      = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"]);
            Int32 IdDistribuidor = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdEmpresaMaster"]);
            //obj.CambiarEstadoRuta(IdDistribuidor, IdUsuario);
            DataTable DtLis = new DataTable();

            DtLis.Columns.Add("CodigoCliente", typeof(String));
            DtLis.Columns.Add("CodigoEmpleado", typeof(String));
            DtLis.Columns.Add("DiasVisita", typeof(String));

            foreach (GridViewRow row in GV_RUTA.Rows)
            {
                DataRow drog = DtLis.NewRow();

                drog["CodigoCliente"]  = Convert.ToString(row.Cells[0].Text.ToString());
                drog["CodigoEmpleado"] = row.Cells[1].Text.ToString();
                drog["DiasVisita"]     = Convert.ToString(row.Cells[2].Text.ToString());
                DtLis.Rows.Add(drog);

                //obj.insertarRuta(row.Cells[0].Text.ToString(),
                //    row.Cells[1].Text.ToString(),
                //    row.Cells[2].Text.ToString(),
                //    IdUsuario, 1);
            }
            obj.insertarRutaV2(Convert.ToInt32(IdUsuario), 1, DtLis);
            String mensajeScript = @"<script type='text/javascript'>
                       swal({
                title: ""Operacion Exitosa"",
                icon: ""success"",
                dangerMode: false,
            })
                  </script>";

            ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScript, false);
            DataTable dt = new DataTable();

            GV_RUTA.DataSource = dt;
            GV_RUTA.DataBind();
        }
Ejemplo n.º 7
0
        protected void BtnValidar_Click(object sender, EventArgs e)
        {
            _cts = new CancellationTokenSource();
            LimparView();
            AtualizarProgresso(0);

            if (!FileUpload1.HasFile || string.IsNullOrWhiteSpace(FileUpload1.PostedFile.FileName))
            {
                Utils.ExibirMensagem("Atenção", "Selecionar um arquivo.Favor verificar", Util.Enum.TipoMensagem.Alerta, this);
                FileUpload1.Focus();
            }
            else
            {
                FileUpload1.Enabled = false;
                var inicio = DateTime.Now;

                try
                {
                    ValidarArquivo();

                    var fim = DateTime.Now;
                    AtualizarView(fim - inicio);
                }
                catch (XmlException)
                {
                    AtualizarProgresso(100);
                    Utils.ExibirMensagem("Erro", "Arquivo no formato inválido. Favor verificar", Util.Enum.TipoMensagem.Erro, this);
                }
                catch (OperationCanceledException)
                {
                    AtualizarProgresso(100);
                    Utils.ExibirMensagem("Erro", "Operação cancelada pelo usuário", Util.Enum.TipoMensagem.Erro, this);
                }
                catch (SchemaXmlException ex)
                {
                    AtualizarProgresso(100);
                    TxtMsg.Value += ex.Message;
                    Utils.ExibirMensagem("Erro", "Arquivo com estrutura inválido. Favor verificar", Util.Enum.TipoMensagem.Erro, this);
                }
                catch (Exception ex)
                {
                    AtualizarProgresso(100);
                    TxtMsg.Value += ex.Message;
                    Utils.ExibirMensagem("Erro", "Arquivo inválido. Favor verificar", Util.Enum.TipoMensagem.Erro, this);
                }
                finally
                {
                    FileUpload1.Enabled = true;
                }
            }
        }
Ejemplo n.º 8
0
    protected void ClearAllData()
    {
        try
        {
            txtParti.Text       = "";
            grdTrans.DataSource = null;
            grdTrans.DataBind();

            FileUpload1.Focus();
        }
        catch (Exception Ex)
        {
            ExceptionLogging.SendErrorToText(Ex);
        }
    }
Ejemplo n.º 9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!IsPostBack)
         {
             FileUpload1.Focus();
         }
         ScriptManager.GetCurrent(this).AsyncPostBackTimeout = 500000;
     }
     catch (Exception Ex)
     {
         ExceptionLogging.SendErrorToText(Ex);
     }
 }
        public void subir()
        {
            if (Gv_Producto.Rows.Count < 1)
            {
                String mensajeScriptnm = @"<script type='text/javascript'>
                       swal({
                title: ""Seleccione Cliente. Txt"",
                icon: ""warning"",
                dangerMode: false,
            })
                  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScriptnm, false);
                FileUpload1.Focus();
                return;
            }

            Int32 IdUsuario      = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"]);
            Int32 IdDistribuidor = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdEmpresaMaster"]);

            //     obj.CambiarEstadoCliente(IdDistribuidor, IdUsuario);
            foreach (GridViewRow row in Gv_Producto.Rows)
            {
                //Int32 IdDistribuidor, String CodigoCliente,String Nombre,
                //String Direccion,String CodigoCanal, String Tipo,String Parm1,
                //String Param2, String Param3, String Param4, String Param5,
                //String Param6, String Param7, String Param8, String Param9, Int32 Usuario,Int32 Estado)

                obj.InsertarCliente(IdDistribuidor, row.Cells[0].Text.ToString(), row.Cells[1].Text.ToString(),
                                    row.Cells[2].Text.ToString(), row.Cells[3].Text.ToString(), row.Cells[4].Text.ToString(),
                                    row.Cells[5].Text.ToString(), row.Cells[6].Text.ToString(), row.Cells[7].Text.ToString(),
                                    row.Cells[8].Text.ToString(), row.Cells[9].Text.ToString(), row.Cells[10].Text.ToString(),
                                    row.Cells[11].Text.ToString(), row.Cells[12].Text.ToString(), row.Cells[13].Text.ToString(),
                                    IdUsuario, 1);
            }
            String mensajeScript = @"<script type='text/javascript'>
                       swal({
                title: ""Operacion Exitosa"",
                icon: ""success"",
                dangerMode: false,
            })
                  </script>";

            ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScript, false);
            DataTable dt = new DataTable();

            Gv_Producto.DataSource = dt;
            Gv_Producto.DataBind();
        }
Ejemplo n.º 11
0
        public bool checkInput()
        {
            bool flag = true;

            if (ddlType.SelectedItem.Value == "0")
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('请选择内容')</script>", false);
                ddlType.Focus();
                flag = false;
            }
            else if (string.IsNullOrEmpty(tags.Text))
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('编号为空')</script>", false);
                tags.Focus();
                flag = false;
            }
            else if (string.IsNullOrEmpty(txtDate.Text))
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('依赖时间为空')</script>", false);
                txtDate.Focus();
                flag = false;
            }
            else if (string.IsNullOrEmpty(txtHours.Text))
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('维修时间为空')</script>", false);
                txtHours.Focus();
                flag = false;
            }
            else if (string.IsNullOrEmpty(txtRecords.Text))
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('处置内容为空')</script>", false);
                txtRecords.Focus();
                flag = false;
            }
            else if (!FileUpload1.HasFile)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('请选择上传图片')</script>", false);
                FileUpload1.Focus();
                flag = false;
            }
            return(flag);
        }
Ejemplo n.º 12
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        string ext = Path.GetExtension(FileUpload1.PostedFile.FileName);
        string pic = Guid.NewGuid() + ext;
        string p   = Server.MapPath("ProductImages");

        if (!p.EndsWith("\\"))
        {
            p += "\\";
        }
        p += pic;
        FileUpload1.PostedFile.SaveAs(p);
        Response.Write("file uploaded");
        Response.Write(pic);


        string     q   = "insert into product_Detail values(@id,@image,@name,@price,@detail,@category,@rating,@date)";
        SqlCommand cmd = new SqlCommand(q, con);

        cmd.Parameters.Add("@id", SqlDbType.Int).Value               = Convert.ToInt32(TextBox3.Text);
        cmd.Parameters.Add("@image", SqlDbType.NVarChar).Value       = pic;
        cmd.Parameters.Add("@name", SqlDbType.VarChar).Value         = TextBox4.Text;
        cmd.Parameters.Add("@price", SqlDbType.Int).Value            = Convert.ToInt32(TextBox6.Text);
        cmd.Parameters.Add("@detail", SqlDbType.NVarChar).Value      = TextBox5.Text;
        cmd.Parameters.Add("@category", SqlDbType.VarChar, 50).Value = DropDownList1.SelectedValue;
        cmd.Parameters.Add("@rating", SqlDbType.Int).Value           = Convert.ToInt32(DropDownList2.SelectedValue);
        cmd.Parameters.Add("@date", SqlDbType.Date).Value            = System.DateTime.Now;

        cmd.ExecuteNonQuery();

        getid();
        cmd.Dispose();
        con.Close();
        TextBox4.Text = "";
        TextBox5.Text = "";
        TextBox6.Text = "";
        FileUpload1.Focus();
        Label3.Text = "* Last New Product Added successfully.";
    }
Ejemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //// Create a merge document and set it's properties
            //MergeDocument document = MergeDocument.Merge( MapPath( "../PDFs/DocumentA.pdf" ), MapPath( "../PDFs/DocumentB.pdf" ));

            //// Append additional PDF
            //document.Append( MapPath( "../PDFs/DocumentC.pdf" ) );
            //// Append 3 pages from an aditional PDF
            //document.Append( MapPath( "../PDFs/DocumentD.pdf" ), 1, 3 );

            //// Outputs the merged document to the current web page
            //document.DrawToWeb( "MergePDFs.pdf" );
            string       usuarioConectado      = (String)Session["usuario"];
            string       senhaConectado        = (String)Session["senha"];
            GoldenAccess servicoDeAutenticacao = new GoldenAccess("http://localhost:3271/GoldenAccess.soap");

            LightInfocon.GoldenAccess.General.User usuarioGoldenAccess = new LightInfocon.GoldenAccess.General.User(usuarioConectado, senhaConectado);
            try
            {
                usuarioGoldenAccess = servicoDeAutenticacao.Authenticate(usuarioConectado, senhaConectado);
            }
            catch (Exception ex)
            {
                string erro = ex.Message;
            }
            if (usuarioGoldenAccess.IsAuthenticated)
            {
                FileUpload1.Focus();
            }
            else
            {
                //Caso não seja o mesmo usuário, este será redirecionado para o login e a sessão será limpa.
                erro = "Usuário não autenticado";
                Session.Add("erro", erro);
                Session.Abandon();
                Server.Transfer("login.aspx");
            }
        }
Ejemplo n.º 14
0
 protected void txtempCode_TextChanged(object sender, EventArgs e)
 {
     {
         try
         {
             string Empcode = txtempCode.Text.Trim().Split(Constants.splitseperator)[0].ToString().Trim();
             bool   Auth    = Masters.GetCodeValidation("EmpCode", Empcode);
             if (Auth)
             {
                 MessageBox("Emp Code is Already Exist");
                 txtempCode.Text = "";
                 txtempCode.Focus();
             }
             else
             {
                 FileUpload1.Focus();
             }
         }
         catch
         {
         }
     }
 }
Ejemplo n.º 15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        FileUpload1.Focus();
        Label8.Visible = false;
        if (!IsPostBack)
        {
            cn.Open();
            cmd.Connection  = cn;
            cmd.CommandText = "select first_name, last_name  from login_detail where username=@username";
            cmd.Parameters.AddWithValue("@username", Session["username"].ToString());
            Session["firstName"] = "";
            reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                Session["firstName"] = reader["first_name"].ToString();
            }
            Label1.Text = Session["firstName"].ToString();
            Label2.Text = reader["last_name"].ToString();
            reader.Close();
            cmd.Parameters.Clear();
            cmd.CommandText = "select photo from profile_picture where username=@username";
            cmd.Parameters.AddWithValue("@username", Session["username"].ToString());

            try
            {
                string filepath = cmd.ExecuteScalar().ToString();
                ImageButton1.ImageUrl = filepath;
            }
            catch (Exception ex)
            {
                ImageButton1.ImageUrl = "~/profilepic/avatar.jpg";
            }
            cn.Close();
            cmd.Parameters.Clear();
        }
    }
Ejemplo n.º 16
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            //to hold the vendor credentials
            SmsVendorCredentials smsVendorCredentials = new SmsVendorCredentials();

            //general vendor credentials
            string vendorCode     = ddlVendors.SelectedValue;
            string vendorPassword = txtVendorPassword.Text;

            //for postpaid vendors
            string postpaidSecreteKey = txtKey.Text;

            //for prepaid vendors
            string prepaidCertificateFile     = FileUpload1.FileName;
            string prepaidCertificatePassword = txtCertPassword.Text;

            //user who is doing the assignment
            string assignedBy = Session["Username"].ToString();

            //get the vendor type based on vendor code
            data_table = data_file.GetArea(vendorCode);

            //we failed to get the type of vendor
            if (data_table == null || data_table.Rows.Count == 0)
            {
                ShowMessage("Failed to get vendor type for vendor: " + vendorCode, true);
                return;
            }

            //get the vendor type
            string vendorType = data_table.Rows[0]["VendorType"].ToString().ToUpper();

            if (vendorCode.Equals(""))
            {
                ShowMessage("Please Select a vendor ", true);
                ddlVendors.Focus();
            }
            else if (vendorPassword.Equals(""))
            {
                ShowMessage("Please Enter a password", true);
                txtVendorPassword.Focus();
            }
            else if (vendorType == SmsVendorCredentials.VENDOR_TYPE_POSTPAID && postpaidSecreteKey.Equals(""))
            {
                ShowMessage("Please Enter a secrete key", true);
                txtKey.Focus();
            }
            else if (vendorType == SmsVendorCredentials.VENDOR_TYPE_PREPAID && prepaidCertificateFile.Equals(""))
            {
                ShowMessage("Please Upload a certficate file", true);
                FileUpload1.Focus();
            }
            else if (vendorType == SmsVendorCredentials.VENDOR_TYPE_PREPAID && prepaidCertificatePassword.Equals(""))
            {
                ShowMessage("Please Enter the Certficate Password", true);
                txtCertPassword.Focus();
            }
            else
            {
                //assign the vendor credentials
                smsVendorCredentials.vendorCode     = vendorCode;
                smsVendorCredentials.vendorPassword = vendorPassword;
                smsVendorCredentials.vendorType     = vendorType;
                smsVendorCredentials.assignedBy     = assignedBy;


                if (vendorType == SmsVendorCredentials.VENDOR_TYPE_POSTPAID)
                {
                    //if the vendor is postpaid, we just need their secret key
                    smsVendorCredentials.vendorType        = SmsVendorCredentials.VENDOR_TYPE_POSTPAID;
                    smsVendorCredentials.postpaidSecretKey = postpaidSecreteKey;
                }
                else if (vendorType == SmsVendorCredentials.VENDOR_TYPE_PREPAID)
                {
                    string filename  = Path.GetFileName(FileUpload1.FileName);
                    string extension = Path.GetExtension(filename);

                    string   pathToFile = @"E:\SMSUploads\Certificates\";
                    DateTime todaydate  = DateTime.Now;
                    string   datetoday  = todaydate.ToString().Replace("/", "-").Replace(":", "-").Replace(" ", "-");
                    string   filepath   = pathToFile + filename + "_" + datetoday + extension;
                    if (!Directory.Exists(pathToFile))
                    {
                        Directory.CreateDirectory(pathToFile);
                    }

                    FileUpload1.SaveAs(filepath);

                    //if the vendor is prepaid, we need the certificate and the certificate password
                    //assign the certificate details
                    smsVendorCredentials.vendorType                 = SmsVendorCredentials.VENDOR_TYPE_PREPAID;
                    smsVendorCredentials.prepaidCertificatePath     = filepath;
                    smsVendorCredentials.prepaidCertificatePassword = prepaidCertificatePassword;
                }

                //save the SMS Vendor Credentials
                string res_mask = Process_file.SaveSmsVendorCredentials(smsVendorCredentials);

                //check if we managed to save the credentials
                if (res_mask == "SAVED")
                {
                    ShowMessage("VENDOR CREDENTIALS ASSIGNED SUCCESSFULLY", false);
                    txtName.Text = "";
                    LoadVendorCredentials();
                }
                else
                {
                    ShowMessage("VENDOR CREDENTIALS NOT ASSIGNED", true);
                }
            }
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message, true);
        }
    }
        protected void BtnGuardar_Click(object sender, EventArgs e)
        {
            if (GvSubir.Rows.Count < 1)
            {
                String mensajeScriptnm = @"<script type='text/javascript'>
                swal({
                title: ""Seleccione  Txt"",
                icon: ""warning"",
                dangerMode: false,
                })
                </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScriptnm, false);
                FileUpload1.Focus();
                return;
            }
            String Msj = "";

            if (DDTipoUusario.SelectedValue == "0")
            {
                string msj3 = @"<script type='text/javascript'>
                       swal({
                title: ""Seleccione Tipo Usuario"",
                icon: ""warning"",
                dangerMode: true,
            })
                  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(System.Web.UI.Page), "mensaje", msj3, false);
                return;
            }

            if (TxtFecha.Value == "")
            {
                string msj3 = @"<script type='text/javascript'>
                       swal({
                title: ""Seleccione Fecha"",
                icon: ""warning"",
                dangerMode: true,
            })
                  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(System.Web.UI.Page), "mensaje", msj3, false);

                return;
            }
            DateTime dttim = DateTime.ParseExact("01/" + TxtFecha.Value.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);

            String fecha = dttim.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);

            Int32 IdDistribuidor = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdEmpresaMaster"]);
            Int32 usuario        = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"]);

            try {
                foreach (GridViewRow row in GvSubir.Rows)
                {
                    Msj = obj.InsertMetaUsuario(IdDistribuidor, row.Cells[0].Text.ToString(),
                                                Convert.ToInt32(DDTipoUusario.SelectedValue), fecha,
                                                float.Parse(row.Cells[1].Text.ToString()), usuario);
                }

                //Msj = obj.InsertMetaUsuario(IdDistribuidor, Convert.ToInt32(DDTipoUusario.SelectedValue),
                //    "01/"+TxtFecha.Value.ToString(),float.Parse(TxtMonto.Value.ToString()), usuario);

                if (Msj == "Exito")
                {
                    string error = @"<script type='text/javascript'>
                       swal({
                title: ""Operacion Exitosa"",
              icon: ""success"",
                dangerMode: false,
            })
                  </script>";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", error, false);
                    listarMeta();
                    busar();
                    Panel_Listar.Visible = true;
                    PanelAgregar.Visible = false;
                    DataTable dt = new DataTable();
                    GvSubir.DataSource = dt;
                    GvSubir.DataBind();
                    listarMeta();
                    LblTotal.Text = "";
                }
                else
                {
                    string menssajeScript = "<script type='text/javascript'>"
                                            + " swal({" +

                                            "title: '" + DDTipoUusario.SelectedItem.ToString() + " " + Msj.ToString() + "'," +
                                            " icon: 'warning'," +
                                            "  dangerMode: true," +
                                            "   })  </script>";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
                }
                listarMeta();
            }
            catch (Exception ex)
            {
                StackTrace st    = new StackTrace(ex, true);
                StackFrame frame = st.GetFrames().Where(f => !String.IsNullOrEmpty(f.GetFileName()) &&
                                                        f.GetILOffset() != StackFrame.OFFSET_UNKNOWN &&
                                                        f.GetNativeOffset() != StackFrame.OFFSET_UNKNOWN &&
                                                        !f.GetMethod().Module.Assembly.GetName().Name.Contains("mscorlib")).First();

                string        MachineName = System.Environment.MachineName;
                string        UserName    = System.Environment.UserName.ToUpper();
                string        Mensaje     = ex.Message;
                StringBuilder builder     = new StringBuilder(Mensaje);
                builder.Replace("'", "");
                int    LineaError     = frame.GetFileLineNumber();
                string Proyecto       = frame.GetMethod().Module.Assembly.GetName().Name;
                string Clase          = frame.GetMethod().DeclaringType.Name;
                string metodo         = frame.GetMethod().Name;
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: '" + builder.ToString() + "'," +
                                        " icon: 'warning'," +
                                        "  dangerMode: true," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);


                return;
            }
            busar();
        }
Ejemplo n.º 18
0
    protected void Button1_Click1(object sender, EventArgs e)
    {
        string logtime = "[ " + DateTime.Now.ToLocalTime().ToString() + " ]";

        TextBox3.Text = "";

        if (FileUpload1.HasFile)
        {
            try
            {
                //upload package file to web server
                TextBox3.Text = logtime + "Upload ComCare timesheet file to server...\r\n";
                string fileName = Path.Combine(Server.MapPath("~/Upload"), FileUpload1.FileName);
                FileUpload1.SaveAs(fileName);
                TextBox3.Text = TextBox3.Text + logtime + "Upload timesheet file to server successfully.\r\n";
                // Instantiate SSIS application object
                Microsoft.SqlServer.Dts.Runtime.Application myApplication = new Microsoft.SqlServer.Dts.Runtime.Application();
                string fileName3 = Path.Combine(Server.MapPath("~/Upload"), "LoadComCareTemesheet.dtsx");
                // TextBox3.Text = TextBox3.Text+logtime + "Loading import package from file system...\r\n";
                string fileName2 = fileName3.Replace(@"\", @"\\");
                //string SSISLocation = "C:\\SSIS\\KyperaToTechone_TF.dtsx";
                Package myPackage = myApplication.LoadPackage(@fileName2, null);
                // TextBox3.Text = TextBox3.Text + logtime + "Loading import package paramter name and value...\r\n";
                // myPackage.Variables[TextBox1.Text].Value = TextBox2.Text;
                // Execute package
                TextBox3.Text = TextBox3.Text + logtime + "Starting loading timesheet file into data warehouse table...\r\n";
                DTSExecResult myResult = myPackage.Execute();
                // Show the execution result
                TextBox3.Text = TextBox3.Text + logtime + "Loading result: " + myResult.ToString() + " \r\n";
                TextBox3.Text = TextBox3.Text + "  =========Begin check the result========\r\n";
                //check records in csv and database table
                //check csv files
                int ft_csv = 0;
                //手工指定 csv文件所在路径,需要修改
                // string strConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\ASABIITool - Dev\\Upload';Extended Properties='text;HDR=Yes;FMT=Delimited'");  //连接数据。  Data Source为CSV文件存在的目录
                string          strConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Jerry Shen\\ASPnet\\ASABIITool - Dev2\\Upload';Extended Properties='text;HDR=Yes;FMT=Delimited'"); //连接数据。  Data Source为CSV文件存在的目录
                OleDbConnection conn    = new OleDbConnection(strConn);
                OleDbCommand    comm1   = new OleDbCommand("select count(*) from [CURRENT_PA_EXPORT.csv]", conn);
                try
                {
                    conn.Open();
                    ft_csv = (int)comm1.ExecuteScalar();

                    TextBox3.Text = TextBox3.Text + " == Begin to check results from Timesheet CSV files == \r\n";
                    TextBox3.Text = TextBox3.Text + " Total records in CURRENT_PA_EXPORT.csv is :" + ft_csv.ToString() + " \r\n";
                    TextBox3.Text = TextBox3.Text + " == Check CSV files finished == \r\n";
                }
                catch (Exception ee)
                {
                    TextBox3.Text = TextBox3.Text + " == Begin to check results from Timesheet CSV files == \r\n";
                    TextBox3.Text = TextBox3.Text + "#Read CSV File ERROR# " + ee.Message + " .Please try again!\r\n";
                }
                finally
                {
                    conn.Close();
                }



                //check records in database querey
                int           ft_db   = 0;
                string        connStr = ConfigurationManager.ConnectionStrings["ASADWHConnectionString"].ConnectionString;
                SqlConnection connsql = new SqlConnection(connStr);
                try
                {
                    TextBox3.Text = TextBox3.Text + "\r\n";
                    TextBox3.Text = TextBox3.Text + " == Begin to check records using database query == \r\n";

                    if (connsql.State.ToString() == "Closed")
                    {
                        connsql.Open();
                    }
                    //check financil transaction data  (most types)
                    string sqlstr = "SELECT count(*) from asadwh.dbo.CC_Timesheetfile_import  ";

                    SqlCommand Cmd = new SqlCommand(sqlstr, connsql);
                    ft_db         = (int)Cmd.ExecuteScalar();
                    TextBox3.Text = TextBox3.Text + "Total records in CC_Timesheetfile_import is  :" + ft_db.ToString() + " \r\n";
                    TextBox3.Text = TextBox3.Text + " == Check database table finished == \r\n";
                }

                catch (Exception eee)
                {
                    TextBox3.Text = "#Query From Database ERROR# " + eee.Message + " .Please try again!";
                }
                finally
                {
                    connsql.Close();
                }


                TextBox3.Text = TextBox3.Text + "  =========Import Timsheet File Conclusion========= \r\n";
                if (ft_db == ft_csv)
                {
                    TextBox3.Text = TextBox3.Text + "[GOOD!]the Timesheet file records in CSV is the same with the ones got from database query \r\n";
                }
                else
                {
                    TextBox3.Text = TextBox3.Text + "[OOPS!]the Timesheet file records in CSV is not the same with the ones got from database query. Please check! \r\n";
                }


                GridView1.Visible = true;
                GridView1.DataBind();
            }
            catch (Exception ee)
            {
                TextBox3.Text = logtime + "Loading fail and Erros is: " + ee.Message + " \r\n";
            }
        }


        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "SystemMessage", "alert('" + "Please select a timesheet file !" + "');", true);
            FileUpload1.Focus();
        }
    }
Ejemplo n.º 19
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        int ticketId = 0;

        if (FileUpload1.HasFile)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "upload", "alert('Please click on upload button after selecting file to attach')", true);
            lblMessage.Text      = "Please click on upload button after selecting file to attach";
            lblMessage.ForeColor = System.Drawing.Color.Red;
            FileUpload1.Focus();
            return;
        }
        if (ddlTicketType.SelectedIndex == 0)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Ticket type", "alert('Please select ticket type')", true);
            //lblMessage.Text = "Please select ticket type";
            //lblMessage.ForeColor = System.Drawing.Color.Red;
            ddlTicketType.Focus();
            return;
        }
        if (string.IsNullOrEmpty(txtTicketSummary.Text))
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ticket summary", "alert('Please enter ticket summary')", true);
            //lblMessage.Text = "Please enter ticket summary";
            //lblMessage.ForeColor = System.Drawing.Color.Red;
            txtTicketSummary.Focus();
            return;
        }
        if (string.IsNullOrEmpty(txtDetails.Value))
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "details", "alert('Please enter Details')", true);
            //lblMessage.Text = "Please enter Details";
            //lblMessage.ForeColor = System.Drawing.Color.Red;
            txtDetails.Focus();
            return;
        }
        ticketId = objTicket.AddTicket(0, lblEmpId.Text, ddlTicketType.SelectedItem.Text, txtTicketSummary.Text.Replace("'", ""), txtDetails.Value.Replace("'", ""), DateTime.Now, "Not Assigned Yet", "No ETA set", "Priority Not Set", "Active", Convert.ToInt32(lblUid.Text));

        if (ticketId != 0)
        {
            bool result = objTicket.UpdateImages(ticketId, lblEmpId.Text);
            lblMessage.Text      = "Ticket raised successfully you can view your ticket status in 'View your past tickets' page";
            lblMessage.ForeColor = System.Drawing.Color.Blue;
            // SendEmail(ticketId);
            string screen = "";
            if (GridView1.Rows.Count > 0)
            {
                screen = "Yes";
            }
            else
            {
                screen = "No";
            }
            string body = PopulateBody(ticketId.ToString(), lblUserName.Text, ddlTicketType.SelectedItem.Text, txtTicketSummary.Text, txtDetails.Value, screen);
            SendHtmlFormattedEmail(ticketId.ToString(), body);
            ClearAll();
        }
        else
        {
            lblMessage.Text = "Something went wrong please trhy again";
        }
    }
        public void subir()
        {
            if (Gv_Producto.Rows.Count < 1)
            {
                String mensajeScriptnm = @"<script type='text/javascript'>
                       swal({
                title: ""Seleccione Producto Txt"",
                icon: ""warning"",
                dangerMode: false,
            })
                  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScriptnm, false);
                FileUpload1.Focus();
                return;
            }
            Int32 IdDistribuidor = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdEmpresaMaster"]);
            Int32 IdUsuario      = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"]);
            //obj.UpdateProducto(IdDistribuidor, IdUsuario);



            DataTable DtLis = new DataTable();

            DtLis.Columns.Add("IdProductoTxt", typeof(string));
            DtLis.Columns.Add("NombrePro", typeof(string));
            DtLis.Columns.Add("Precio", typeof(String));
            DtLis.Columns.Add("StockDisponible", typeof(Int32));

            foreach (GridViewRow row in Gv_Producto.Rows)
            {
                DataRow drog = DtLis.NewRow();

                drog["IdProductoTxt"]   = Convert.ToString(row.Cells[0].Text.ToString());
                drog["NombrePro"]       = row.Cells[1].Text.ToString();
                drog["Precio"]          = Convert.ToString(row.Cells[2].Text.ToString());
                drog["StockDisponible"] = Convert.ToInt32(row.Cells[3].Text.ToString());
                DtLis.Rows.Add(drog);
            }
            obj.insertarProducto(Convert.ToInt32(DDFabricante.SelectedValue), 1, IdUsuario, 1, DtLis);
            //foreach (GridViewRow row in Gv_Producto.Rows)
            //{
            //    //    Int32 IdProcuto, Int32 IdFabricante,Int32 TipoUsuario, Int32 Stock,String NombreProducto,
            //    //float Precio, String Imagen,Int32 Usuario, Int32 Estado
            //   // 12077014 | SUBL Bombon CajE 24 20x8g | 9.46 | 788
            //    obj.insertarProducto(Convert.ToString(row.Cells[0].Text.ToString()),Convert.ToInt32(DDFabricante.SelectedValue),1,
            //        Convert.ToInt32(row.Cells[3].Text.ToString()), row.Cells[1].Text.ToString(),
            //        Convert.ToString(row.Cells[2].Text.ToString()),
            //        "IMG", IdUsuario, 1);
            //}
            String mensajeScript = @"<script type='text/javascript'>
                       swal({
                title: ""Operacion Exitosa"",
                icon: ""success"",
                dangerMode: false,
            })
                  </script>";

            ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScript, false);
            DataTable dt = new DataTable();

            Gv_Producto.DataSource = dt;
            Gv_Producto.DataBind();
            listar();
            PanelSubirNuevo.Visible = false;
            PanelListar.Visible     = true;
        }
Ejemplo n.º 21
0
    protected void Button1_Click1(object sender, EventArgs e)
    {
        GridView2.Visible = false;
        Label9.Visible    = false;

        string logtime = "[ " + DateTime.Now.ToLocalTime().ToString() + " ]";

        TextBox3.Text = "";


        if (DropDownList1.SelectedItem.Text == "--Please select a pay period--")
        {
            Response.Write("<script LANGUAGE='JavaScript' >alert('Please select a Pay Period!')</script>");
            DropDownList1.Focus();
        }
        else
        {
            if (FileUpload1.HasFile)
            {
                try
                {
                    string SSIS_UploadFolder = ConfigurationManager.AppSettings["SSIS_UploadFolder_CIM"].ToString();
                    //upload package file to web server
                    TextBox3.Text = logtime + "Upload ComCare timesheet file to server...\r\n";
                    // string fileName = Path.Combine(Server.MapPath("~/Upload"), FileUpload1.FileName);
                    //  FileUpload1.SaveAs("\\\\clank\\COMCARETEST\\CCToCIM\\Upload\\" + FileUpload1.FileName);
                    string ComCareTimesheetUpload = ConfigurationManager.AppSettings["ComCareTimesheetUpload-Stage"].ToString();
                    FileUpload1.SaveAs(ComCareTimesheetUpload + FileUpload1.FileName);

                    TextBox3.Text = TextBox3.Text + logtime + "Upload timesheet file to server successfully.\r\n";
                    // Instantiate SSIS application object
                    Microsoft.SqlServer.Dts.Runtime.Application myApplication = new Microsoft.SqlServer.Dts.Runtime.Application();
                    string fileName3 = Path.Combine(Server.MapPath("~/Upload"), "LoadComCareTemesheet.dtsx");
                    // TextBox3.Text = TextBox3.Text+logtime + "Loading import package from file system...\r\n";
                    string fileName2 = fileName3.Replace(@"\", @"\\");
                    //string SSISLocation = "C:\\SSIS\\KyperaToTechone_TF.dtsx";
                    Package myPackage = myApplication.LoadPackage(@fileName2, null);
                    myPackage.Variables["LoadFolder"].Value = SSIS_UploadFolder;
                    // TextBox3.Text = TextBox3.Text + logtime + "Loading import package paramter name and value...\r\n";
                    // myPackage.Variables[TextBox1.Text].Value = TextBox2.Text;
                    // Execute package
                    TextBox3.Text = TextBox3.Text + logtime + "Starting loading timesheet file into data warehouse table...\r\n";
                    ShowProcessBar();
                    DTSExecResult myResult = myPackage.Execute();
                    // Show the execution result
                    TextBox3.Text = TextBox3.Text + logtime + "Loading result: " + myResult.ToString() + " \r\n";
                    System.Threading.Thread.Sleep(2000);
                    ExitProcessBar();
                    TextBox3.Text = TextBox3.Text + "  =========Begin check the result========\r\n";
                    //check records in csv and database table
                    //check csv files
                    int ft_csv = 0;
                    //手工指定 csv文件所在路径,需要修改
                    // string strConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\\Jerry Shen\\ASPnet\\ASABIITool - Dev2\\Upload';Extended Properties='text;HDR=Yes;FMT=Delimited'");  //连接数据。  Data Source为CSV文件存在的目录
                    // string strConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='\\\\clank\\COMCARETEST\\CCToCIM\\Upload';Extended Properties='text;HDR=Yes;FMT=Delimited'");  //连接数据。  Data Source为CSV文件存在的目录
                    string          ComCareTimesheetUpload_csv = ConfigurationManager.AppSettings["ComCareTimesheetUpload-csv"].ToString();
                    string          strConn = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='text;HDR=Yes;FMT=Delimited'", ComCareTimesheetUpload_csv); //连接数据。  Data Source为CSV文件存在的目录
                    OleDbConnection conn    = new OleDbConnection(strConn);
                    OleDbCommand    comm1   = new OleDbCommand("select count(*) from [CURRENT_PA_EXPORT.csv]", conn);
                    try
                    {
                        conn.Open();
                        ft_csv = (int)comm1.ExecuteScalar();

                        TextBox3.Text = TextBox3.Text + " == Begin to check results from Timesheet CSV files == \r\n";
                        TextBox3.Text = TextBox3.Text + " Total records in CURRENT_PA_EXPORT.csv is :" + ft_csv.ToString() + " \r\n";
                        TextBox3.Text = TextBox3.Text + " == Check CSV files finished == \r\n";
                    }
                    catch (Exception ee)
                    {
                        TextBox3.Text = TextBox3.Text + " == Begin to check results from Timesheet CSV files == \r\n";
                        TextBox3.Text = TextBox3.Text + "#Read CSV File ERROR# " + ee.Message + " .Please try again!\r\n";
                    }
                    finally
                    {
                        conn.Close();
                    }



                    //check records in database querey
                    int           ft_db   = 0;
                    string        connStr = ConfigurationManager.ConnectionStrings["ASADWHConnectionString"].ConnectionString;
                    SqlConnection connsql = new SqlConnection(connStr);
                    try
                    {
                        TextBox3.Text = TextBox3.Text + "\r\n";
                        TextBox3.Text = TextBox3.Text + " == Begin to check records using database query == \r\n";

                        if (connsql.State.ToString() == "Closed")
                        {
                            connsql.Open();
                        }
                        //check financil transaction data  (most types)
                        string sqlstr = "SELECT count(*) from asadwh.dbo.CC_Timesheetfile_import  where p_orders=1 ";

                        SqlCommand Cmd = new SqlCommand(sqlstr, connsql);
                        ft_db         = (int)Cmd.ExecuteScalar();
                        TextBox3.Text = TextBox3.Text + "Total records in CC_Timesheetfile_import is  :" + ft_db.ToString() + " \r\n";
                        TextBox3.Text = TextBox3.Text + " == Check database table finished == \r\n";
                    }

                    catch (Exception eee)
                    {
                        TextBox3.Text = "#Query From Database ERROR# " + eee.Message + " .Please try again!";
                    }
                    finally
                    {
                        connsql.Close();
                    }



                    TextBox3.Text = TextBox3.Text + "  =========Import Timsheet File Conclusion========= \r\n";
                    if (ft_db == ft_csv)
                    {
                        TextBox3.Text = TextBox3.Text + "[GOOD!]the Timesheet file records in CSV is the same with the ones got from database query \r\n";
                        //move file to archive
                        TextBox3.Text = TextBox3.Text + logtime + "Start to move the timsheet file to archive folder.... \r\n";
                        string fileNameSer = "CURRENT_PA_EXPORT.csv";



                        string dateString  = DateTime.Now.ToLocalTime().ToString();
                        string dateString1 = dateString.Replace("/", "");
                        string dateString2 = dateString1.Replace(" ", "");
                        string dateString3 = dateString2.Replace(":", "");

                        string filenameDes = "CURRENT_PA_EXPORT" + dateString3 + ".csv";

                        string ComCareTimesheetServerFolder        = ConfigurationManager.AppSettings["ComCareTimesheetServerFolder"].ToString();
                        string ComCareTimesheetServerArchiveFolder = ConfigurationManager.AppSettings["ComCareTimesheetServerArchiveFolder"].ToString();

                        // string sourcePath = @"\\\\clank\\comcaretest\\Payroll";
                        // string targetPath = @"\\\\clank\\comcaretest\\Payroll\\Archive";
                        string sourcePath = @ComCareTimesheetServerFolder;
                        string targetPath = @ComCareTimesheetServerArchiveFolder;
                        // Use Path class to manipulate file and directory paths.
                        string sourceFile = System.IO.Path.Combine(sourcePath, fileNameSer);
                        string destFile   = System.IO.Path.Combine(targetPath, filenameDes);

                        // To copy a file to another location and
                        // overwrite the destination file if it already exists.
                        try
                        {
                            System.IO.File.Copy(sourceFile, destFile, true);
                            //delete from origial file
                            try
                            {
                                System.IO.File.Delete(sourceFile);
                                TextBox3.Text = TextBox3.Text + logtime + "Finish moving the timsheet file to archive folder....";

                                Button5.Enabled = true;
                            }
                            catch (Exception e3)
                            {
                                TextBox3.Text = TextBox3.Text + logtime + "#Delete file fail and ERROR is: # " + e3.Message + " .Please try again!";
                            }
                        }
                        catch (Exception eeee)
                        {
                            TextBox3.Text = TextBox3.Text + logtime + "#Move file fail and ERROR is: # " + eeee.Message + " .Please try again!";
                        }
                    }
                    else
                    {
                        TextBox3.Text = TextBox3.Text + "[OOPS!]the Timesheet file records in CSV is not the same with the ones got from database query. Please check! \r\n";
                    }



                    GridView1.Visible = true;
                    GridView1.DataBind();
                }
                catch (Exception ee)
                {
                    TextBox3.Text = logtime + "Loading fail and Erros is: " + ee.Message + " \r\n";
                }
            }


            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "SystemMessage", "alert('" + "Please select a timesheet file !" + "');", true);
                FileUpload1.Focus();
            }
        }
    }
Ejemplo n.º 22
0
    private void UpdateTicket()
    {
        if (FileUpload1.HasFile)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Upload", "alert('Please click on upload button after selecting file to attach')", true);
            //lblError.Text = "Please click on upload button after selecting file to attach";
            //lblError.ForeColor = System.Drawing.Color.Red;
            FileUpload1.Focus();
            return;
        }
        if (lblAccess.Text == "1")
        {
            if (ddlAssignedTo.SelectedIndex == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Select user", "alert('Please select user to assign ticket')", true);
                //lblError.Text = "Please select user to assign ticket";
                //lblError.ForeColor = Color.Red;
                ddlAssignedTo.Focus();
                return;
            }
            bool result = objTicket.UpdateTicket(ddlStatus.SelectedItem.Text, ddlAssignedTo.SelectedItem.Text, txtETA.Text, Convert.ToInt32(txtTicketId.Text), ddlType.SelectedItem.Text);
            if (string.IsNullOrEmpty(txtAdd.Value) == false)
            {
                bool result2 = objTicket.UpdateNotes(txtAdd.Value.Replace("'", ""), Convert.ToInt32(txtTicketId.Text), lblUser.Text);
            }
            GetNotes();
            GetInternalNotes();
            txtAdd.Value = string.Empty;
            if (result == true)
            {
                string assign = "";
                if (ddlAssignedTo.SelectedIndex == 0)
                {
                    assign = lblAssigned.Text;
                }
                else
                {
                    assign = ddlAssignedTo.SelectedItem.Text;
                }
                string body = PopulateBody(txtTicketId.Text, lblUser.Text, ddlStatus.SelectedItem.Text, txtCreatedBY.Text, txtType.Text, txtSummary.Text, txtDetails.Value, assign, txtETA.Text, txtNotes.Value);
                SendHtmlFormattedEmail(txtTicketId.Text, body);
                //SendEmail(Convert.ToInt32(txtTicketId.Text));
                lblError.Text      = "Updated successfully";
                lblError.ForeColor = Color.Blue;
            }
            else
            {
                lblError.Text      = "Somthing went wrong.. Please try again";
                lblError.ForeColor = Color.Red;
            }
        }
        else if (lblTeam.Text == "4")
        {
            bool result = objTicket.UpdateTicket(ddlStatus.SelectedItem.Text, ddlAssignedTo.SelectedItem.Text, txtETA.Text, Convert.ToInt32(txtTicketId.Text), txtType.Text);
            if (string.IsNullOrEmpty(txtAdd.Value) == false)
            {
                bool result2 = objTicket.UpdateNotes(txtAdd.Value, Convert.ToInt32(txtTicketId.Text), lblUser.Text);
            }
            GetNotes();
            txtAdd.Value = string.Empty;
            if (result == true)
            {
                string assign = "";
                if (ddlAssignedTo.SelectedIndex == 0)
                {
                    assign = lblAssigned.Text;
                }
                else
                {
                    assign = ddlAssignedTo.SelectedItem.Text;
                }


                string body = PopulateBody(txtTicketId.Text, lblUser.Text, ddlStatus.SelectedItem.Text, txtCreatedBY.Text, txtType.Text, txtSummary.Text, txtDetails.Value, assign, txtETA.Text, txtNotes.Value);
                SendHtmlFormattedEmail(txtTicketId.Text, body);
                //SendEmail(Convert.ToInt32(txtTicketId.Text));
                lblError.Text      = "Updated successfully";
                lblError.ForeColor = Color.Blue;
            }
            else
            {
                lblError.Text      = "Somthing went wrong.. Please try again";
                lblError.ForeColor = Color.Red;
            }
        }
        else
        {
            if (string.IsNullOrEmpty(txtAdd.Value))
            {
                lblError.Text = "Enter notes";
                txtAdd.Focus();
                lblError.ForeColor = Color.Red;
                return;
            }
            bool result1 = objTicket.UpdateStatus(ddlStatus.SelectedItem.Text, Convert.ToInt32(txtTicketId.Text));
            bool result2 = objTicket.UpdateNotes(txtAdd.Value, Convert.ToInt32(txtTicketId.Text), lblUser.Text);
            GetNotes();
            txtAdd.Value = string.Empty;
            if (result2 == true)
            {
                string assign = "";
                if (ddlAssignedTo.SelectedIndex == 0)
                {
                    assign = lblAssigned.Text;
                }
                else
                {
                    assign = ddlAssignedTo.SelectedItem.Text;
                }
                string body = PopulateBody(txtTicketId.Text, lblUser.Text, ddlStatus.SelectedItem.Text, txtCreatedBY.Text, txtType.Text, txtSummary.Text, txtDetails.Value, assign, txtETA.Text, txtNotes.Value);
                SendHtmlFormattedEmail(txtTicketId.Text, body);
                //SendEmail(Convert.ToInt32(txtTicketId.Text));
                lblError.Text      = "Updated successfully";
                lblError.ForeColor = Color.Blue;
            }
            else
            {
                lblError.Text      = "Somthing went wrong.. Please try again";
                lblError.ForeColor = Color.Red;
            }
        }
    }
Ejemplo n.º 23
0
 protected void Page_Load(object sender, EventArgs e)
 {
     FileUpload1.Focus();
 }
Ejemplo n.º 24
0
        public void subir()
        {
            if (GvStock.Rows.Count < 1)
            {
                String mensajeScriptnm = @"<script type='text/javascript'>
                swal({
                title: ""Seleccione Stock Txt"",
                icon: ""warning"",
                dangerMode: false,
                })
                </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScriptnm, false);
                FileUpload1.Focus();
                return;
            }

            Int32 IdUsuario = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"]);
            //obj.CambiarEstadoStock(Convert.ToInt32(DDFabricante.SelectedValue), IdUsuario);
            DataTable DtLis = new DataTable();

            DtLis.Columns.Add("IdAlmacen", typeof(string));
            DtLis.Columns.Add("IdProductoTxt", typeof(string));
            DtLis.Columns.Add("Stock", typeof(Int32));

            foreach (GridViewRow row in GvStock.Rows)
            {
                DataRow drog = DtLis.NewRow();

                drog["IdAlmacen"]     = row.Cells[0].Text.ToString();
                drog["IdProductoTxt"] = row.Cells[1].Text.ToString();
                drog["Stock"]         = Convert.ToInt32(row.Cells[2].Text.ToString());
                DtLis.Rows.Add(drog);
            }

            String Msj = "";

            Msj = obj.SubirStockAlmacen(IdUsuario, Convert.ToInt32(DDFabricante.SelectedValue), 1, DtLis);
            //foreach (GridViewRow row in GvStock.Rows)
            //{


            //    obj.InsertarStock(row.Cells[0].Text.ToString(),row.Cells[1].Text.ToString(),Convert.ToInt32(row.Cells[2].Text.ToString()),
            //    IdUsuario, 1,Convert.ToInt32(DDFabricante.SelectedValue));

            //}
            if (Msj != "")
            {
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: '" + Msj + "'," +
                                        " icon: 'success'," +
                                        "  dangerMode: false," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
            }
            else
            {
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: 'ocurrio un error'," +
                                        " icon: 'warning'," +
                                        "  dangerMode: true," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
            }
            DataTable dt = new DataTable();

            GvStock.DataSource = dt;
            GvStock.DataBind();
            DtLis.Rows.Clear();
        }
    protected void Button1_Click1(object sender, EventArgs e)
    {
        string logtime = "[ " + DateTime.Now.ToLocalTime().ToString() + " ]";

        TextBox3.Text = "";

        if (FileUpload1.HasFile)
        {
            if (CheckBox1.Checked == true)
            {
                if (TextBox1.Text == "")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "SystemMessage", "alert('Parameter name and value cannot be NULL');", true);
                    TextBox1.Focus();
                }
                else
                {
                    try
                    {
                        //upload package file to web server
                        TextBox3.Text = logtime + "Uploade package file to server...\r\n";
                        string fileName = Path.Combine(Server.MapPath("~/Upload"), FileUpload1.FileName);
                        TextBox3.Text = FileUpload1.FileName;
                        FileUpload1.SaveAs(fileName);
                        TextBox3.Text = TextBox3.Text + logtime + "Upload package file to server successfully.\r\n";
                        // Instantiate SSIS application object
                        Microsoft.SqlServer.Dts.Runtime.Application myApplication = new Microsoft.SqlServer.Dts.Runtime.Application();
                        TextBox3.Text = TextBox3.Text + logtime + "Loading package from file system...\r\n";
                        string fileName2 = fileName.Replace(@"\", @"\\");
                        //string SSISLocation = "C:\\SSIS\\KyperaToTechone_TF.dtsx";
                        Package myPackage = myApplication.LoadPackage(@fileName2, null);
                        TextBox3.Text = TextBox3.Text + logtime + "Loading package paramter name and value...\r\n";
                        myPackage.Variables[TextBox1.Text].Value = TextBox2.Text;
                        // Execute package
                        TextBox3.Text = TextBox3.Text + logtime + "Executing package...\r\n";
                        DTSExecResult myResult = myPackage.Execute();
                        // Show the execution result
                        TextBox3.Text = TextBox3.Text + logtime + "Package executed result: " + myResult.ToString() + " \r\n";
                    }
                    catch (Exception ee)
                    {
                        TextBox3.Text = logtime + "Package executed fail and Erros is: " + ee.Message + " \r\n";
                    }
                }
            }
            else
            {
                try
                {
                    //upload package file to web server
                    TextBox3.Text = logtime + "Uploade package file to server...\r\n";
                    string fileName = Path.Combine(Server.MapPath("~/Upload"), FileUpload1.FileName);
                    FileUpload1.SaveAs(fileName);
                    TextBox3.Text = TextBox3.Text + logtime + "Upload package file to server successfully.\r\n";
                    Microsoft.SqlServer.Dts.Runtime.Application myApplication = new Microsoft.SqlServer.Dts.Runtime.Application();
                    TextBox3.Text = TextBox3.Text + logtime + "Loading package from file system...\r\n";
                    string fileName2 = fileName.Replace(@"\", @"\\");
                    // string SSISLocation = "C:\\SSIS\\KyperaToTechone_TF.dtsx";
                    Package myPackage = myApplication.LoadPackage(@fileName2, null);
                    // Execute package
                    TextBox3.Text = TextBox3.Text + logtime + "Executing package...\r\n";
                    DTSExecResult myResult = myPackage.Execute();
                    // Show the execution result
                    TextBox3.Text = TextBox3.Text + logtime + "Package executed result: " + myResult.ToString() + " \r\n";
                }
                catch (Exception ee)
                {
                    TextBox3.Text = logtime + "Package executed fail and Erros is: " + ee.Message + " \r\n";
                }
            }
        }

        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "SystemMessage", "alert('" + "Please select a SSIS package file !" + "');", true);
            FileUpload1.Focus();
        }
    }
Ejemplo n.º 26
0
 protected void btnSubmitData_Click(object sender, EventArgs e)
 {
     #region VALidation
     if (txtApplicantName.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter your name!');</script>");
         txtApplicantName.Focus();
         return;
     }
     else if (txtFathersName.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter father name!');</script>");
         txtApplicantName.Focus();
         return;
     }
     else if (txtMothersName.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter mothers name!');</script>");
         txtMothersName.Focus();
         return;
     }
     else if (txtDOB.Value == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please select Date of birth!');</script>");
         txtDOB.Focus();
         return;
     }
     else if (txtUIDNumber.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter UID Number!');</script>");
         txtUIDNumber.Focus();
         return;
     }
     else if (txt10Schoolname.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter 10 School name!');</script>");
         txt10Schoolname.Focus();
         return;
     }
     else if (txt10thBoard.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter 10 Board ie. U.p Board/CBSE!');</script>");
         txt10thBoard.Focus();
         return;
     }
     else if (txt10RollNo.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please Enter Roll No');</script>");
         txt10thBoard.Focus();
         return;
     }
     else if (txt10YoP.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter year of passing for 10!');</script>");
         txt10YoP.Focus();
         return;
     }
     else if (txt10TotalMarks.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Total marks fro 10!');</script>");
         txt10TotalMarks.Focus();
         return;
     }
     else if (txt10MarksObtained.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter marks obtained for 10!');</script>");
         txt10MarksObtained.Focus();
         return;
     }
     else if (txt10Percentage.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter percentage for 10!');</script>");
         txt10Percentage.Focus();
         return;
     }
     else if (txt12Schoolname.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter 12 School name!');</script>");
         txt10Schoolname.Focus();
         return;
     }
     else if (txt12thBoard.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter 12 Board ie. U.p Board/CBSE!');</script>");
         txt10thBoard.Focus();
         return;
     }
     else if (txt12RollNo.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please Enter Roll No');</script>");
         txt10thBoard.Focus();
         return;
     }
     else if (txt12YoP.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter 12 Year of Passing!');</script>");
         txt12YoP.Focus();
         return;
     }
     else if (txt12TotalMarks.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter 12 total marks!');</script>");
         txt12TotalMarks.Focus();
         return;
     }
     else if (txt12MarksObtained.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter 12 marks obtained!');</script>");
         txt12MarksObtained.Focus();
         return;
     }
     else if (txt12Percentage.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter 12 percentage!');</script>");
         txt12Percentage.Focus();
         return;
     }
     else if (txtAddressCorr.Text.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Correspondence Address!');</script>");
         txtAddressCorr.Focus();
         return;
     }
     else if (txtPinCorr.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter pin code!');</script>");
         txtPinCorr.Focus();
         return;
     }
     else if (ddlDIsrictCorr.SelectedValue == "0")
     {
         Response.Write("<script type='text/javascript'>alert('select District Name!');</script>");
         ddlDIsrictCorr.Focus();
         return;
     }
     else if (txtAddress_per.Text.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Permanent Address!');</script>");
         txtAddress_per.Focus();
         return;
     }
     else if (txtPin_Per.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Pin Code for permanent address!');</script>");
         txtPin_Per.Focus();
         return;
     }
     else if (ddlDIsrictCorr.SelectedValue == "0")
     {
         Response.Write("<script type='text/javascript'>alert('select District!');</script>");
         ddlDIsrictCorr.Focus();
         return;
     }
     else if (txtCategory.Text.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Category!');</script>");
         txtCategory.Focus();
         return;
     }
     else if (Session["photoFileName"] == null)
     {
         Response.Write("<script type='text/javascript'>alert('Upload Photograph!');</script>");
         FileUpload1.Focus();
         return;
     }
     else if (Session["SignFileName"] == null)
     {
         Response.Write("<script type='text/javascript'>alert('Upload Signature!');</script>");
         FileUpload2.Focus();
         return;
     }
     else if (email.Text == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Email ID!');</script>");
         email.Focus();
         return;
     }
     else if (phone.Text == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Phone Number!');</script>");
         phone.Focus();
         return;
     }
     else if (!chkAccepttheAgreement.Checked)
     {
         Response.Write("<script type='text/javascript'>alert('Please Select the Declaration Agreement!');</script>");
         chkAccepttheAgreement.Focus();
         return;
     }
     #endregion
     UserRegistration user = new UserRegistration();
     user.Name                    = txtApplicantName.Value;
     user.FatherName              = txtFathersName.Value;
     user.MothersName             = txtMothersName.Value;
     user.DOB                     = txtDOB.Value;
     user.UID_No                  = txtUIDNumber.Value;
     user.school_Name_HSS         = txt10Schoolname.Value;
     user.Board_Name_HSS          = txt10thBoard.Value;
     user.Roll_No_HSS             = txt10RollNo.Value;
     user.YOP_HSS                 = txt10YoP.Value;
     user.Total_Marks_HSS         = txt10TotalMarks.Value;
     user.Marks_Obtained_HSS      = txt10MarksObtained.Value;
     user.Marks_Perc_HSS          = txt10Percentage.Value;
     user.school_Name_SSC         = txt12Schoolname.Value;
     user.Board_Name_SSC          = txt12thBoard.Value;
     user.Roll_No_SSC             = txt12RollNo.Value;
     user.YOP_SSC                 = txt12YoP.Value;
     user.Total_Marks_SSC         = txt12TotalMarks.Value;
     user.Marks_Obtained_SSC      = txt12MarksObtained.Value;
     user.Marks_Per_SSC           = txt12Percentage.Value;
     user.AddressPermanent        = txtAddress_per.Text;
     user.PinCodePermanent        = txtPin_Per.Value;
     user.DistrictPermanent       = ddlDistrict.SelectedValue;
     user.StatePermanent          = ddlState.SelectedValue;
     user.AddressCorrespondence   = txtAddressCorr.Text;
     user.PinCodeCorrespondence   = txtPinCorr.Value;
     user.DistrictCorrespondence  = ddlDIsrictCorr.SelectedValue;
     user.StateCorrespondence     = ddlState.SelectedValue;
     user.PictureName             = Session["photoFileName"].ToString();
     user.Signature               = Session["SignFileName"].ToString();
     user.RegistrationMode        = "Education";
     user.Candidate_Category      = txtCategory.Text;
     user.isEconomicalDisabledGen = ChkEcDisabledGen.Checked == true ? true : false;
     int CandidateId = 0;
     if (new Utilities().submitUserData(user, ref CandidateId))
     {
         doPayment(user);
         string RegistrationNumber = DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/" + CandidateId;
         // Response.Write("<script type='text/javascript'>alert('Candidate Registered With Registration Number " + RegistrationNumber + "');</script>");
     }
 }
Ejemplo n.º 27
0
    protected void btnCargar_Click(object sender, EventArgs e)
    {
        try
        {
            HttpFileCollection uploads = HttpContext.Current.Request.Files;
            for (int i = 0; i < uploads.Count; i++)
            {
                HttpPostedFile upload = uploads[i];
                if (upload.ContentLength == 0)
                {
                    continue;
                }
                string c = System.IO.Path.GetFileName(upload.FileName);
                try
                {
                    string ruta = Server.MapPath("context/Archivos/") + c;
                    upload.SaveAs(ruta);
                }
                catch (Exception Exp)
                {
                    throw (Exp);
                }
            }
            if (FileUpload1.PostedFile != null)
            {
                HttpPostedFile attFile          = FileUpload1.PostedFile;
                int            attachFileLength = attFile.ContentLength;
                if (attachFileLength > 0)
                {
                    if (FileUpload1.PostedFile.ContentLength > 0)
                    {
                        string Extension      = Path.GetExtension(FileUpload1.PostedFile.FileName);
                        string inFileName     = Path.GetFileName(FileUpload1.PostedFile.FileName);
                        string pathDataSource = Server.MapPath("context/Archivos/") + inFileName;

                        //string conStr = "";
                        if (Extension == ".xls" || Extension == ".xlsx" || Extension == ".xlsm")
                        {
                            string    CadenaConexion = @"driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};
                                    driverid=1046;dbq=" + pathDataSource;
                            DataTable ds             = null;
                            try
                            {
                                using (OdbcConnection conn = new OdbcConnection(CadenaConexion))
                                {
                                    conn.Open();
                                    using (OdbcCommand command = conn.CreateCommand())
                                    {
                                        //consulta para mostrar en hoja de excel
                                        command.CommandText = "SELECT * FROM [CargaDatos$]";
                                        OdbcDataAdapter ad = new OdbcDataAdapter(command);
                                        ds = new DataTable();
                                        ad.Fill(ds);
                                        conn.Close();

                                        int i = 0;

                                        foreach (DataRow fila in ds.Rows)
                                        {
                                            i++;
                                            if (fila[0].ToString().Trim() == "0" || fila[0].ToString().Trim() == "")
                                            {
                                                fila.Delete();
                                            }
                                        }
                                        ViewState["dataSource"]       = ds;
                                        ViewState["plantillaCargada"] = "true";
                                        gridExcel.DataSource          = ds;
                                        gridExcel.DataBind();
                                        if (ViewState["plantillaCargada"].ToString() == "true")
                                        {
                                            btnGrabar.Enabled  = false;
                                            btnGrabar.CssClass = "btn btn-danger";
                                            lblMensaje.Text    = "Esta plantilla ya ha sido cargada en la base de datos";
                                            divMensaje.Attributes.Add("class", "alert alert-success  col-md-8");
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Response.Write(ex.Message.ToString());
                            }
                        }
                        else
                        {
                            //Show your error in any error controls
                        }
                    }
                    else
                    {
                        FileUpload1.Focus();
                        gridExcel.DataSource = null;
                        gridExcel.DataBind();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            //throw ex;
            lblMensaje.Text = ex.Message;
        }


        //la conexion donde se encuentra el archivo para ser mostrado en el gridview
    }
Ejemplo n.º 28
0
    protected void ImportDataFromExcel(string FilePath, string Extension, string ConStr, string isHDR)
    {
        string TrxType = "", GlCode = "";

        DT = new DataTable();

        try
        {
            switch (Extension.ToLower())
            {
            case ".xls":     //Excel 97-03
                ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR={1}'";
                break;

            case ".xlsx":     //Excel 07
                ConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                break;
            }

            ConStr = String.Format(ConStr, FilePath, isHDR);
            OleDbConnection  connExcel = new OleDbConnection(ConStr);
            OleDbCommand     cmdExcel  = new OleDbCommand();
            OleDbDataAdapter oda       = new OleDbDataAdapter();
            cmdExcel.Connection = connExcel;
            connExcel.Open();
            cmdExcel.CommandText = "Select * From [Sheet1$]";
            oda.SelectCommand    = cmdExcel;
            oda.Fill(DT);
            connExcel.Close();

            if (DT.Rows.Count > 0)
            {
                if (txtParti.Text.ToString() == "")
                {
                    txtParti.Text = "By System";
                }

                //  Remover temporary data from table userwise
                FU.RemoveData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), Session["MID"].ToString());
                for (int i = 0; i <= DT.Rows.Count - 1; i++)
                {
                    GlCode = FU.GetGlCode(DT.Rows[i][0].ToString(), DT.Rows[i][1].ToString());
                    if (DT.Rows[i][5].ToString().ToUpper() == "CR")
                    {
                        TrxType = "1";
                    }
                    else
                    {
                        TrxType = "2";
                    }

                    if (GlCode.ToString() == "3" && TrxType.ToString() == "1")
                    {
                        //Added for loan case
                        Result     = 1;
                        TotalDrAmt = Convert.ToDouble(DT.Rows[i][3].ToString());
                        DataTable LoanDT = new DataTable();
                        LoanDT = MT.GetLoanTotalAmount(DT.Rows[i][0].ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), Session["EntryDate"].ToString());

                        if (LoanDT.Rows[0]["IntCalType"].ToString() == "1" || LoanDT.Rows[0]["IntCalType"].ToString() == "2")
                        {
                            //  For Interest Receivable
                            if (Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()) > 0 && TotalDrAmt >= Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()))
                            {
                                if (LoanDT.Rows[0]["IntCalType"].ToString() == "1")
                                {
                                    // Interest Received credit to GL 11
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), LoanDT.Rows[0]["InterestRecGl"].ToString(), LoanDT.Rows[0]["InterestRecSub"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           DT.Rows[i][3].ToString(), "1", "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                    if (Result > 0)
                                    {
                                        if (Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()) > 0)
                                        {
                                            // Interest Received Amt Credit To 4 In AVS_LnTrx
                                            Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestRecSub"].ToString(), DT.Rows[i][2].ToString(), "4", "1", "7", "Interest Received Credit", DT.Rows[i][3].ToString(), Session["MID"].ToString());
                                        }
                                    }
                                }
                                else if (LoanDT.Rows[0]["IntCalType"].ToString() == "2")
                                {
                                    // Interest Received credit to GL 3
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode.ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           DT.Rows[i][3].ToString(), "1", "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());
                                }
                                TotalDrAmt = Convert.ToDouble(TotalDrAmt - Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()));
                            }
                            else if (Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()) > 0 && TotalDrAmt > 0)
                            {
                                if (LoanDT.Rows[0]["IntCalType"].ToString() == "1")
                                {
                                    // Interest Received credit to GL 11
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), LoanDT.Rows[0]["InterestRecGl"].ToString(), LoanDT.Rows[0]["InterestRecSub"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           TotalDrAmt.ToString(), "1", "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                    if (Result > 0)
                                    {
                                        if (Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()) > 0)
                                        {
                                            // Interest Received Amt Credit To 4 In AVS_LnTrx
                                            Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestRecSub"].ToString(), DT.Rows[i][2].ToString(), "4", "1", "7", "Interest Received Credit", TotalDrAmt.ToString(), Session["MID"].ToString());
                                        }
                                    }
                                }
                                else if (LoanDT.Rows[0]["IntCalType"].ToString() == "2")
                                {
                                    // Interest Received credit to GL 3
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode.ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           TotalDrAmt.ToString(), "1", "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());
                                }
                                TotalDrAmt = 0;
                            }

                            //  For Interest
                            if (LoanDT.Rows[0]["IntCalType"].ToString() == "1")
                            {
                                if (Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())) > 0 && TotalDrAmt >= Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())))
                                {
                                    //interest Credit to GL 11
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), LoanDT.Rows[0]["InterestGl"].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString())).ToString(), "1", "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                    if (Result > 0)
                                    {
                                        //Current Interest Debit To 2 In AVS_LnTrx
                                        Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), "2", "2", "7", "Interest Debit", LoanDT.Rows[0]["CurrInterest"].ToString(), Session["MID"].ToString());
                                    }

                                    if (Result > 0)
                                    {
                                        //Current Interest Credit To 2 In AVS_LnTrx
                                        Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), "2", "1", "7", "Interest Credit", Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString())).ToString(), Session["MID"].ToString());
                                    }

                                    if (Result > 0)
                                    {
                                        //interest Applied Contra To GL 11
                                        Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), LoanDT.Rows[0]["InterestGl"].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                               Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString())).ToString(), "2", "11", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                        if (Result > 0)
                                        {
                                            //interest Applied Credit to GL 100
                                            Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), "100", LoanDT.Rows[0]["PlAccNo1"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                                   Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString())).ToString(), "1", "11", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());
                                        }
                                    }

                                    TotalDrAmt = Convert.ToDouble(TotalDrAmt - Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())));
                                }
                                else if (Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())) > 0 && TotalDrAmt > 0)
                                {
                                    //interest Credit to GL 11
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), LoanDT.Rows[0]["InterestGl"].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           TotalDrAmt.ToString(), "1", "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                    if (Result > 0)
                                    {
                                        //Current Interest Debit To 2 In AVS_LnTrx
                                        Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), "2", "2", "7", "Interest Debit", LoanDT.Rows[0]["CurrInterest"].ToString(), Session["MID"].ToString());
                                    }

                                    if (Result > 0)
                                    {
                                        //Current Interest Credit To 2 In AVS_LnTrx
                                        Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), "2", "1", "7", "Interest Credit", TotalDrAmt.ToString(), Session["MID"].ToString());
                                    }

                                    if (Result > 0)
                                    {
                                        //interest Applied Contra To GL 11
                                        Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), LoanDT.Rows[0]["InterestGl"].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                               TotalDrAmt.ToString(), "2", "11", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                        if (Result > 0)
                                        {
                                            //interest Applied Credit to GL 100
                                            Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), "100", LoanDT.Rows[0]["PlAccNo1"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                                   TotalDrAmt.ToString(), "1", "11", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());
                                        }
                                    }

                                    TotalDrAmt = 0;
                                }
                            }
                            else if (LoanDT.Rows[0]["IntCalType"].ToString() == "2")
                            {
                                if (Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())) > 0 && TotalDrAmt >= Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())))
                                {
                                    //interest Received Credit to GL 3
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode.ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString())).ToString(), TrxType, "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                    //  Added As Per ambika mam Instruction 22-06-2017
                                    if (Result > 0)
                                    {
                                        //interest Applied Debit To GL 3
                                        Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode.ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                               Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString())).ToString(), "2", "11", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                        if (Result > 0)
                                        {
                                            //interest Applied Credit to GL 100
                                            Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), "100", LoanDT.Rows[0]["PlAccNo1"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                                   Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString())).ToString(), "1", "11", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());
                                        }
                                    }
                                    TotalDrAmt = Convert.ToDouble(TotalDrAmt - Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())));
                                }
                                else if (Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())) > 0 && TotalDrAmt > 0)
                                {
                                    //interest Received Credit to GL 3
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode.ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           TotalDrAmt.ToString(), "1", "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                    //  Added As Per ambika mam Instruction 22-06-2017
                                    if (Result > 0)
                                    {
                                        //interest Applied Debit To GL 3
                                        Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode.ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                               TotalDrAmt.ToString(), "2", "11", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                        if (Result > 0)
                                        {
                                            //interest Applied Credit to GL 100
                                            Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), "100", LoanDT.Rows[0]["PlAccNo1"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                                   TotalDrAmt.ToString(), "1", "11", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());
                                        }
                                    }
                                    TotalDrAmt = 0;
                                }
                            }

                            //Principle O/S Credit To Specific GL (e.g 3)
                            if (Convert.ToDouble(LoanDT.Rows[0]["Principle"].ToString()) > 0 && TotalDrAmt >= Convert.ToDouble(LoanDT.Rows[0]["Principle"].ToString()))
                            {
                                Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode.ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                       LoanDT.Rows[0]["Principle"].ToString(), "1", "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());
                                TotalDrAmt = Convert.ToDouble(TotalDrAmt - Convert.ToDouble(LoanDT.Rows[0]["Principle"].ToString()));
                            }
                            else if (Convert.ToDouble(LoanDT.Rows[0]["Principle"].ToString()) > 0 && TotalDrAmt > 0)
                            {
                                Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode.ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                       TotalDrAmt.ToString(), "1", "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());
                                TotalDrAmt = 0;
                            }
                        }
                        else if (LoanDT.Rows[0]["IntCalType"].ToString() == "3")
                        {
                            //  Credit to principle (E.G Glcode is '3')
                            Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode.ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                   TotalDrAmt.ToString(), "1", "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());

                            if (Result > 0)
                            {
                                if (TotalDrAmt >= Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["InterestRec"].ToString()) +
                                                                   Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) +
                                                                                    Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString()))))
                                {
                                    TotalDrAmt = Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["InterestRec"].ToString()) +
                                                                  Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) +
                                                                                   Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())));
                                }

                                //  Debit to principle (E.G Glcode is '3')
                                Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode.ToString(), DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                       TotalDrAmt.ToString(), "2", "7", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                //  For Interest Receivable
                                if (Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()) > 0 && TotalDrAmt >= Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()))
                                {
                                    // Interest Received credit to GL 11
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), LoanDT.Rows[0]["InterestRecGl"].ToString(), LoanDT.Rows[0]["InterestRecSub"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           DT.Rows[i][3].ToString(), "1", "7", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                    if (Result > 0)
                                    {
                                        if (Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()) > 0)
                                        {
                                            // Interest Received Amt Credit To 4 In AVS_LnTrx
                                            Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestRecSub"].ToString(), DT.Rows[i][2].ToString(), "4", "1", "7", "Interest Received Credit", DT.Rows[i][3].ToString(), Session["MID"].ToString());
                                        }
                                    }
                                    TotalDrAmt = Convert.ToDouble(TotalDrAmt - Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()));
                                }
                                else if (Convert.ToDouble(LoanDT.Rows[0]["InterestRec"].ToString()) > 0 && TotalDrAmt > 0)
                                {
                                    // Interest Received credit to GL 11
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), LoanDT.Rows[0]["InterestRecGl"].ToString(), LoanDT.Rows[0]["InterestRecSub"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           TotalDrAmt.ToString(), "1", "7", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                    if (Result > 0)
                                    {
                                        // Interest Received Amt Credit To 4 In AVS_LnTrx
                                        Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestRecSub"].ToString(), DT.Rows[i][2].ToString(), "4", "1", "7", "Interest Received Credit", TotalDrAmt.ToString(), Session["MID"].ToString());
                                    }
                                    TotalDrAmt = 0;
                                }

                                //  For Interest
                                if (Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())) > 0 && TotalDrAmt >= Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())))
                                {
                                    //interest Credit to GL 11
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), LoanDT.Rows[0]["InterestGl"].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString())).ToString(), "1", "7", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                    if (Result > 0 && Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString()) > 0)
                                    {
                                        //Current Interest Debit To 2 In AVS_LnTrx
                                        Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), "2", "2", "7", "Interest Debit", LoanDT.Rows[0]["CurrInterest"].ToString(), Session["MID"].ToString());
                                    }

                                    if (Result > 0)
                                    {
                                        //Current Interest Credit To 2 In AVS_LnTrx
                                        Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), "2", "1", "7", "Interest Credit", Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString())).ToString(), Session["MID"].ToString());
                                    }

                                    TotalDrAmt = Convert.ToDouble(TotalDrAmt - Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())));
                                }
                                else if (Convert.ToDouble(Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["Interest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["Interest"].ToString()) + Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString())) > 0 && TotalDrAmt > 0)
                                {
                                    //interest Credit to GL 11
                                    Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), LoanDT.Rows[0]["InterestGl"].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                                           TotalDrAmt.ToString(), "1", "7", "TR_INT", "0", "01/01/1900", "1003", Session["MID"].ToString());

                                    if (Result > 0 && Convert.ToDouble(Convert.ToDouble(LoanDT.Rows[0]["CurrInterest"].ToString()) < 0 ? "0" : LoanDT.Rows[0]["CurrInterest"].ToString()) > 0)
                                    {
                                        //Current Interest Debit To 2 In AVS_LnTrx
                                        Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), "2", "2", "7", "Interest Debit", LoanDT.Rows[0]["CurrInterest"].ToString(), Session["MID"].ToString());
                                    }

                                    if (Result > 0)
                                    {
                                        //Current Interest Credit To 2 In AVS_LnTrx
                                        Result = FU.InsertLoanTrx(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), DT.Rows[i][1].ToString(), LoanDT.Rows[0]["InterestSub"].ToString(), DT.Rows[i][2].ToString(), "2", "1", "7", "Interest Credit", TotalDrAmt.ToString(), Session["MID"].ToString());
                                    }

                                    TotalDrAmt = 0;
                                }
                            }
                        }
                    }
                    else
                    {
                        Result = FU.InsertData(Session["BRCD"].ToString(), Session["EntryDate"].ToString(), DT.Rows[i][0].ToString(), DT.Rows[i][4].ToString(), GlCode, DT.Rows[i][1].ToString(), DT.Rows[i][2].ToString(), txtParti.Text.ToString(),
                                               DT.Rows[i][3].ToString(), TrxType, "7", "TR", "0", "01/01/1900", "1003", Session["MID"].ToString());
                    }
                }
            }
            else
            {
                WebMsgBox.Show("Rows not exists in excel file...!!", this.Page);
                FileUpload1.Focus();
                return;
            }
        }
        catch (Exception Ex)
        {
            ExceptionLogging.SendErrorToText(Ex);
        }
    }
Ejemplo n.º 29
0
        public void subir()
        {
            if (GvSubir.Rows.Count < 1)
            {
                String mensajeScriptnm = @"<script type='text/javascript'>
                swal({
                title: ""Seleccione  Txt"",
                icon: ""warning"",
                dangerMode: false,
                })
                </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScriptnm, false);
                FileUpload1.Focus();
                return;
            }

            Int32  IdUsuario = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"]);
            String Msj       = "";

            try {
                foreach (GridViewRow row in GvSubir.Rows)
                {
                    Msj = obj.SubirPedidoSugeridoCliente(row.Cells[0].Text.ToString(), Convert.ToDouble(row.Cells[1].Text.ToString()), IdUsuario);
                }
            }
            catch (Exception ex)
            {
                StackTrace st    = new StackTrace(ex, true);
                StackFrame frame = st.GetFrames().Where(f => !String.IsNullOrEmpty(f.GetFileName()) &&
                                                        f.GetILOffset() != StackFrame.OFFSET_UNKNOWN &&
                                                        f.GetNativeOffset() != StackFrame.OFFSET_UNKNOWN &&
                                                        !f.GetMethod().Module.Assembly.GetName().Name.Contains("mscorlib")).First();

                string        MachineName = System.Environment.MachineName;
                string        UserName    = System.Environment.UserName.ToUpper();
                string        Mensaje     = ex.Message;
                StringBuilder builder     = new StringBuilder(Mensaje);
                builder.Replace("'", "");
                int    LineaError     = frame.GetFileLineNumber();
                string Proyecto       = frame.GetMethod().Module.Assembly.GetName().Name;
                string Clase          = frame.GetMethod().DeclaringType.Name;
                string metodo         = frame.GetMethod().Name;
                String M              = "Formato Incorrecto";
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: '" + M.ToString() + "'," +
                                        " icon: 'warning'," +
                                        "  dangerMode: false," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
                return;
            }
            if (Msj != "")
            {
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: '" + Msj + "'," +
                                        " icon: 'success'," +
                                        "  dangerMode: false," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
                PanelListar.Visible = true;
                PanelSubir.Visible  = false;
                ListarClienteSugerido();
                LblTotal.Text = "";
            }
            else
            {
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: 'ocurrio un error'," +
                                        " icon: 'warning'," +
                                        "  dangerMode: true," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
            }
            DataTable dt = new DataTable();

            GvSubir.DataSource = dt;
            GvSubir.DataBind();
            ListarClienteSugerido();
        }
Ejemplo n.º 30
0
        public void subir()
        {
            if (GvSubir.Rows.Count < 1)
            {
                String mensajeScriptnm = @"<script type='text/javascript'>
                swal({
                title: ""Seleccione  Txt"",
                icon: ""warning"",
                dangerMode: false,
                })
                </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScriptnm, false);
                FileUpload1.Focus();
                return;
            }

            Int32  IdUsuario = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"]);
            String Msj       = "";

            try
            {
                DataTable DtLis = new DataTable();
                DtLis.Columns.Add("idPedido", typeof(Int32));
                DtLis.Columns.Add("Producto", typeof(String));
                DtLis.Columns.Add("cantidad", typeof(Int32));
                DtLis.Columns.Add("Precio", typeof(Decimal));
                DtLis.Columns.Add("Usuario", typeof(Int32));

                foreach (GridViewRow row in GvSubir.Rows)
                {
                    DataRow drog = DtLis.NewRow();

                    drog["idPedido"] = Convert.ToInt32(row.Cells[0].Text.ToString());
                    drog["Producto"] = row.Cells[1].Text.ToString().ToString();
                    drog["cantidad"] = Convert.ToInt32(row.Cells[2].Text.ToString());
                    drog["Precio"]   = Decimal.Parse(row.Cells[3].Text.ToString());
                    drog["Usuario"]  = IdUsuario;
                    DtLis.Rows.Add(drog);
                }
                Msj = obj.subiconciliacion(DtLis);
                //foreach (GridViewRow row in GvSubir.Rows)
                //{
                //    Msj = obj.SubirConciliacion(Convert.ToInt32(row.Cells[0].Text.ToString()),
                //     row.Cells[1].Text.ToString(),
                //       Convert.ToInt32(row.Cells[2].Text.ToString()), Decimal.Parse(row.Cells[3].Text.ToString()),
                //       IdUsuario);
                //}
            }
            catch (Exception ex)
            {
                StackTrace st    = new StackTrace(ex, true);
                StackFrame frame = st.GetFrames().Where(f => !String.IsNullOrEmpty(f.GetFileName()) &&
                                                        f.GetILOffset() != StackFrame.OFFSET_UNKNOWN &&
                                                        f.GetNativeOffset() != StackFrame.OFFSET_UNKNOWN &&
                                                        !f.GetMethod().Module.Assembly.GetName().Name.Contains("mscorlib")).First();

                string        MachineName = System.Environment.MachineName;
                string        UserName    = System.Environment.UserName.ToUpper();
                string        Mensaje     = ex.Message;
                StringBuilder builder     = new StringBuilder(Mensaje);
                builder.Replace("'", "");
                int    LineaError     = frame.GetFileLineNumber();
                string Proyecto       = frame.GetMethod().Module.Assembly.GetName().Name;
                string Clase          = frame.GetMethod().DeclaringType.Name;
                string metodo         = frame.GetMethod().Name;
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: '" + builder.ToString() + "'," +
                                        " icon: 'warning'," +
                                        "  dangerMode: false," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
                return;
            }
            if (Msj != "")
            {
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: '" + Msj + "'," +
                                        " icon: 'success'," +
                                        "  dangerMode: false," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);

                LblTotal.Text = "";
            }
            else
            {
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: '" + Msj + "'," +
                                        " icon: 'warning'," +
                                        "  dangerMode: true," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
            }
            DataTable dt = new DataTable();

            GvSubir.DataSource = dt;
            GvSubir.DataBind();
        }