private void ValidaDocref()
        {
            if (tipref.SelectedIndex != -1 && serref.Text.Trim().Length == 4 && numdococ.Text.Trim().Length == 6)
            {
                var BL = new tb_cm_ordendecompracabBL();
                var BE = new tb_cm_ordendecompracab();

                var dt = new DataTable();
                BE.moduloid = "0100";
                BE.local = "001";
                BE.tipodoc = tipref.SelectedValue.ToString();
                BE.serdoc = serref.Text.Trim();
                BE.numdoc = numdococ1.Text.ToString() + numdococ.Text.Trim();
                dt = BL.GetOne(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    serref.Text = dt.Rows[0]["serdoc"].ToString().Trim();
                    var numdoc = dt.Rows[0]["numdoc"].ToString().Trim();
                    numdococ1.Text = Equivalencias.Left(numdoc, 4);
                    numdococ.Text = Equivalencias.Right(numdoc, 6);

                    fechref.Format = DateTimePickerFormat.Short;
                    fechref.Value = Convert.ToDateTime(dt.Rows[0]["fechdoc"]);
                    ctacte.Text = dt.Rows[0]["ctacte"].ToString().Trim();
                    nmruc.Text = dt.Rows[0]["nmruc"].ToString().Trim();
                    ctactename.Text = dt.Rows[0]["ctactename"].ToString().Trim();
                    direc.Text = dt.Rows[0]["direc"].ToString().Trim();
                    moneda.SelectedValue = dt.Rows[0]["moneda"].ToString().Trim();

                    dt.Rows[0]["sigla"].ToString().Trim();
                    txtmoneda.Text = dt.Rows[0]["sigla"].ToString().Trim();
                }
            }
        }
        private void ValidaDocref()
        {
            if (tipref.SelectedIndex != -1 && serref.Text.Trim().Length == 4 && numdococ.Text.Trim().Length == 6)
            {
                tb_cm_ordendecompracabBL BL = new tb_cm_ordendecompracabBL();
                tb_cm_ordendecompracab BE = new tb_cm_ordendecompracab();

                DataTable dt = new DataTable();
                BE.moduloid = "0100";
                BE.local = "001";
                BE.tipodoc = tipref.SelectedValue.ToString();
                BE.serdoc = serref.Text.Trim();
                BE.numdoc = numdococ1.Text.ToString() + numdococ.Text.Trim();
                //BE.numdoc =  numdococ.Text.Trim();
                dt = BL.GetOne(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (local == dt.Rows[0]["localdes"].ToString().Trim())
                    {
                        serref.Text = dt.Rows[0]["serdoc"].ToString().Trim();
                        String numdoc = dt.Rows[0]["numdoc"].ToString().Trim();

                        numdococ1.Text = Equivalencias.Left(numdoc, 4);
                        numdococ.Text = Equivalencias.Right(numdoc, 6);

                        fechref.Format = DateTimePickerFormat.Short;
                        fechref.Value = Convert.ToDateTime(dt.Rows[0]["fechdoc"]);
                        ctacte.Text = dt.Rows[0]["ctacte"].ToString().Trim();
                        nmruc.Text = dt.Rows[0]["nmruc"].ToString().Trim();
                        ctactename.Text = dt.Rows[0]["ctactename"].ToString().Trim();
                        direc.Text = dt.Rows[0]["direc"].ToString().Trim();
                        moneda.SelectedValue = dt.Rows[0]["moneda"].ToString().Trim();

                        String s = dt.Rows[0]["sigla"].ToString().Trim();
                        txtmoneda.Text = dt.Rows[0]["sigla"].ToString().Trim();
                    }
                    else
                    {
                        MessageBox.Show("La Orden de Compra : "
                                            + dt.Rows[0]["numdoc"].ToString().Trim() + "\n"
                                             + "  Esta Destinada a Otro Local !!!");
                        return;
                    }
                }
            }
        }