Exemplo n.º 1
0
 private void ObtenerPago(Janus.Windows.GridEX.GridEX grilla)
 {
     if (grilla.SelectedItems.Count > 0)
     {
         ItemCuentaCorriente icc = (ItemCuentaCorriente)grilla.GetRow().DataRow;
         icc.Pago = Math.Abs(icc.Saldo);
         grilla.Refetch();
     }
 }
Exemplo n.º 2
0
        private void ObtenerPago(Janus.Windows.GridEX.GridEX grilla)
        {
            //if (grilla.CurrentColumn.Key.Equals("Saldo"))
            //{
            DetalleCuentaCorriente dcc = (DetalleCuentaCorriente)grilla.GetRow().DataRow;

            dcc.Pago = Math.Abs(dcc.Saldo);
            grilla.Refetch();
            //}
        }
Exemplo n.º 3
0
 private void gridVariablesUsuario_DoubleClick(object sender, EventArgs e)
 {
     if (gridVariablesUsuario.SelectedItems.Count > 0 && gridVariablesUsuario.SelectedItems[0].GetRow().RowType.Equals(Janus.Windows.GridEX.RowType.Record))
     {
         VariableAuxiliar var          = (VariableAuxiliar)gridVariablesUsuario.GetRow().DataRow;
         FrmInputType     frmInputType = new FrmInputType(var.Descripcion, var, "Valor", var.DataType, typeof(mz.erp.businessrules.comprobantes.VariableAuxiliar));
         frmInputType.ShowDialog();
         gridVariablesUsuario.SetDataBinding(null, null);
         gridVariablesUsuario.SetDataBinding(_uiController.VariablesDeUsuario, null);
     }
 }
        /*
         * private void gridEX1_CellUpdated(object sender, Janus.Windows.GridEX.ColumnActionEventArgs e)
         * {
         *      gridEX1.Refresh();
         * }
         */

        private void gridEX1_SelectionChanged(object sender, EventArgs e)
        {
            bool ok = false;

            if (gridEX1.SelectedItems.Count > 0 && gridEX1.SelectedItems[0].RowType.Equals(Janus.Windows.GridEX.RowType.Record))
            {
                gridEXValores.Refetch();
                object    selected = gridEX1.SelectedItems[0].GetRow().DataRow;
                ArrayList valores  = _uiController.GetValores(selected);
                foreach (object valor in valores)
                {
                    Janus.Windows.GridEX.GridEXRow row = gridEXValores.GetRow(valor);
                    if (row != null)
                    {
                        Janus.Windows.GridEX.GridEXFormatStyle rowStyle = new Janus.Windows.GridEX.GridEXFormatStyle();
                        rowStyle.BackColor = System.Drawing.Color.Red;
                        row.RowStyle       = rowStyle;
                    }
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Hedh ne file-in Excel te dhenat e grides pa ndonje kategorizim te vecante
 /// </summary>
 /// <param name="file"></param>
 /// <param name="grid"></param>
 /// <param name="fushat"></param>
 /// <param name="key"></param>
 /// <param name="llojet"></param>
 /// <param name="id"></param>
 public void ShkruajGride(string file, Janus.Windows.GridEX.GridEX grid,
                          string[] fushat, string[] key, string[] llojet, string id)
 {
     try
     {
         connString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
                      @"Data Source=" + excelPath + "\\" + file +
                      @";Extended Properties=""Excel 8.0;HDR=YES""";
         conn.ConnectionString = connString;
         conn.Open();
         cmd.Connection = conn;
         for (int i = 0; i < grid.RowCount; i++)
         {
             bool total = false;
             if (grid.GetRow(i).Cells[id].Text == "")
             {
                 //nqs eshte rresthi total ath shkruaje ne excel
                 if (grid.TotalRow == Janus.Windows.GridEX.InheritableBoolean.True && i == grid.RowCount - 1)
                 {
                     total = true;
                 }
                 else
                 {
                     continue;
                 }
             }
             string str = "INSERT INTO [" + file.Remove(file.Length - 4) + "$] (";
             for (int j = 0; j < fushat.Length; j++)
             {
                 str += fushat[j] + ",";
             }
             str  = str.Remove(str.Length - 1);
             str += ") VALUES ( ";
             for (int j = 0; j < fushat.Length; j++)
             {
                 if (grid.GetRow(i).Cells[id].Text == "" && total == true && j == 0)
                 {
                     str += "'TOTAL',";
                     continue;
                 }
                 else if (llojet[j] == "char(255)")
                 {
                     str += "'" + grid.GetRow(i).Cells[key[j]].Text.Replace("'", "`") + "',";
                 }
                 else if (llojet[j] == "float")
                 {
                     if (grid.GetRow(i).Cells[key[j]].Value == null)
                     {
                         str += "0,";
                     }
                     else
                     {
                         str += grid.GetRow(i).Cells[key[j]].Value.ToString() + ",";
                     }
                 }
                 else
                 {
                     str += grid.GetRow(i).Cells[key[j]].Text + ",";
                 }
             }
             str             = str.Remove(str.Length - 1);
             str            += ")";
             cmd.CommandText = str;
             cmd.ExecuteNonQuery();
             gabim = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ndodhi një gabim gjatë konvertimit në Excel!"
                         + Environment.NewLine + "Nqs keni të hapur ndonjë skedar Excel me emër " + file +
                         Environment.NewLine + "mbylleni dhe riprovoni të bëni konvertimin në Excel.", "Konvertimi në Excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
         gabim = 1;
     }
     finally
     {
         if (conn.State == System.Data.ConnectionState.Open)
         {
             conn.Close();
         }
     }
 }
Exemplo n.º 6
0
        //public void ShkruajGrideKategori(string file, Janus.Windows.GridEX.GridEX grid,
        //    string[] fushat, string[] key, string[] llojet, string id, string colKategori)
        //{
        //    try
        //    {
        //        connString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
        //               @"Data Source=" + excelPath + "\\" + file +
        //               @";Extended Properties=""Excel 8.0;HDR=YES""";
        //        conn.ConnectionString = connString;
        //        conn.Open();
        //        cmd.Connection = conn;
        //        for (int i = 0; i < grid.RowCount; i++)
        //        {
        //            string str = "";
        //            //nqs eshte rresht kategorizimi

        //            if (grid.GetRow(i).Cells[id].Text == "")
        //            {
        //                if (colKategori == "TAVOLINA")
        //                {
        //                    str = "INSERT INTO [" + file.Remove(file.Length - 4) + "$] (";
        //                    if (grid.GetRow(i).GroupCaption != null)
        //                        str += fushat[0] + ") VALUES ('" + grid.GetRow(i).GroupCaption.Replace("'", "`") + "')";
        //                    else
        //                    {
        //                        str += fushat[0] + ",Vlera) VALUES ('TOTAL', " + grid.GetRow(i).Cells["VLERA"].Value + ")";
        //                    }
        //                }
        //                else //if (colKategori == "EMRI")
        //                {
        //                    str = "INSERT INTO [" + file.Remove(file.Length - 4) + "$] (";
        //                    if (grid.GetRow(i).GroupCaption != null)
        //                        str += fushat[0] + ") VALUES ('" + grid.GetRow(i).GroupCaption.Replace("'", "`") + "')";
        //                    else
        //                    {
        //                        if (grid.Name == "gridBlerjet")
        //                            str += fushat[0] + ",Vlera_e_blerjes, Skonto, Blerja_në_total, Paguar, Detyrimi_ndaj_furnitorit) VALUES ('TOTAL' "
        //                            + ", " + grid.GetRow(i).Cells["VLERA"].Value + "," + grid.GetRow(i).Cells["SKONTO"].Value + "," + grid.GetRow(i).Cells["TOTAL"].Value + "," + grid.GetRow(i).Cells["PAGUAR"].Value +
        //                            ", " + grid.GetRow(i).Cells["DETYRIMI"].Value + ")";
        //                        else if (grid.Name == "gridShitjet")
        //                            str += fushat[0] + ",Vlera_e_shitjes, Skonto, Shitja_në_total, Paguar, Detyrimi_i_klientit) VALUES ('TOTAL' "
        //                            + ", " + grid.GetRow(i).Cells["VLERA"].Value + "," + grid.GetRow(i).Cells["SKONTO"].Value + "," + grid.GetRow(i).Cells["TOTAL"].Value + "," + grid.GetRow(i).Cells["PAGUAR"].Value +
        //                            ", " + grid.GetRow(i).Cells["DETYRIMI"].Value + ")";
        //                    }
        //                }

        //            }
        //            //nqs eshte rresht element
        //            else
        //            {
        //                str = "INSERT INTO [" + file.Remove(file.Length - 4) + "$] (";
        //                for (int j = 0; j < fushat.Length; j++)
        //                    str += fushat[j] + ",";
        //                str = str.Remove(str.Length - 1);
        //                str += ") VALUES ( ";
        //                for (int j = 0; j < fushat.Length; j++)
        //                {
        //                    if (llojet[j] == "char(255)")
        //                        str += "'" + grid.GetRow(i).Cells[key[j]].Text.Replace("'", "`") + "',";
        //                    else if (llojet[j] == "float")
        //                    {
        //                        if (grid.GetRow(i).Cells[key[j]].Text != "")
        //                            str += grid.GetRow(i).Cells[key[j]].Value.ToString() + ",";
        //                        else
        //                            str += "0" + ",";
        //                    }
        //                    else
        //                        str += grid.GetRow(i).Cells[key[j]].Text + ",";

        //                }
        //                str = str.Remove(str.Length - 1);
        //                str += ")";
        //            }
        //            cmd.CommandText = str;
        //            cmd.ExecuteNonQuery();
        //            gabim = 0;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show("Ndodhi një gabim gjatë konvertimit në Excel!"
        //            + Environment.NewLine + "Nqs keni të hapur ndonjë skedar Excel me emër " + file +
        //            Environment.NewLine + "mbylleni dhe riprovoni të bëni konvertimin në Excel.", "Konvertimi në Excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //        gabim = 1;
        //    }
        //    finally
        //    {
        //        if (conn.State == System.Data.ConnectionState.Open)
        //            conn.Close();
        //    }

        //}

        public void ShkruajGrideKategori(string file, Janus.Windows.GridEX.GridEX grid,
                                         string[] fushat, string[] key, string[] llojet, string id)
        {
            try
            {
                connString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
                             @"Data Source=" + excelPath + "\\" + file +
                             @";Extended Properties=""Excel 8.0;HDR=YES""";
                conn.ConnectionString = connString;
                conn.Open();
                cmd.Connection = conn;
                for (int i = 0; i < grid.RowCount; i++)
                {
                    string str = "";
                    str = "INSERT INTO [" + file.Remove(file.Length - 4) + "$] (";
                    if (grid.GetRow(i).RowType == Janus.Windows.GridEX.RowType.GroupHeader)
                    {
                        str += grid.RootTable.Columns[id].Caption.Replace(" ", "_") + ")";
                        str += " VALUES ('" + grid.GetRow(i).Group.Column.Caption + ":" + grid.GetRow(i).GroupCaption + "')";
                    }
                    else if (grid.GetRow(i).RowType == Janus.Windows.GridEX.RowType.TotalRow ||
                             grid.GetRow(i).RowType == Janus.Windows.GridEX.RowType.GroupFooter)
                    {
                        for (int j = 0; j < key.Length; j++)
                        {
                            //if (key[j] == colKategori)
                            //    continue;
                            str += fushat[j] + ",";
                        }
                        str  = str.Substring(0, str.Length - 1);
                        str += ") VALUES ('TOTAL',";
                        for (int j = 0; j < key.Length; j++)
                        {
                            if (j == 0)
                            {
                                continue;
                            }
                            if (llojet[j] == "char(255)")
                            {
                                str += "'" + grid.GetRow(i).Cells[key[j]].Text.Replace("'", "`") + "',";
                            }
                            else if (llojet[j] == "float")
                            {
                                if (grid.GetRow(i).Cells[key[j]].Value == null)
                                {
                                    str += "null,";
                                }
                                else
                                {
                                    str += grid.GetRow(i).Cells[key[j]].Value.ToString() + ",";
                                }
                            }
                            else
                            {
                                str += grid.GetRow(i).Cells[key[j]].Text + ",";
                            }
                        }
                        str  = str.Remove(str.Length - 1);
                        str += ")";
                    }
                    else
                    {
                        for (int j = 0; j < key.Length; j++)
                        {
                            //if (key[j] == colKategori)
                            //    continue;
                            str += fushat[j] + ",";
                        }
                        str  = str.Substring(0, str.Length - 1);
                        str += ") VALUES (";
                        for (int j = 0; j < key.Length; j++)
                        {
                            //if (key[j] == colKategori)
                            //    continue;
                            if (llojet[j] == "char(255)")
                            {
                                str += "'" + grid.GetRow(i).Cells[key[j]].Text.Replace("'", "`") + "',";
                            }
                            else if (llojet[j] == "float")
                            {
                                str += grid.GetRow(i).Cells[key[j]].Value.ToString() + ",";
                            }
                            else
                            {
                                str += grid.GetRow(i).Cells[key[j]].Text + ",";
                            }
                        }
                        str  = str.Remove(str.Length - 1);
                        str += ")";
                    }
                    cmd.CommandText = str;
                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ndodhi një gabim gjatë konvertimit në Excel!"
                                + Environment.NewLine + "Nqs keni të hapur ndonjë skedar Excel me emër " + file +
                                Environment.NewLine + "mbylleni dhe riprovoni të bëni konvertimin në Excel.", "Konvertimi në Excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                gabim = 1;
            }
            finally
            {
                if (conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }