public void refresh_kuhni()
        {
            this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            OracleConnectionParameters connectionParameters = new OracleConnectionParameters(vivaprocess.Global.ora_serv, "kuhni_modul", "kuhni");
            SqlDataSource  ds    = new SqlDataSource(connectionParameters);
            CustomSqlQuery query = new CustomSqlQuery();

            query.Name = "customQuery1";
            query.Sql  = "select ITEM_ID,prod_id as NN,prod_name as NN_КЛИЕНТА,client_name as КЛИЕНТ,reklamac_name as РЕКЛАМАЦИЯ,date_in as ДАТА_ПОСТУПЛ,"
                         + " date_out as ДАТА_ВЫПОЛН from REKLAMAC where date_in is null"
                         + " or (date_in between trunc(ADD_MONTHS((last_day(to_date('" + dateViewZakaz.Text + "','dd.mm.yyyy'))), 0), 'MM')"
                         + " and trunc(last_day(to_date('" + dateViewZakaz.Text + "','dd.mm.yyyy')))) order by PROD_ID, reklamac_name";
            sqlKuhni.Queries.Clear();
            sqlKuhni.Queries.Add(query);
            sqlKuhni.Fill();
            bindKuhni.DataSource = sqlKuhni;
            bindKuhni.DataMember = "customQuery1";
            lookUpKuhni.Properties.DataSource    = bindKuhni;
            lookUpKuhni.Properties.ValueMember   = "ITEM_ID";
            lookUpKuhni.Properties.DisplayMember = "РЕКЛАМАЦИЯ";
            lookUpKuhni.Properties.PopulateColumns();
            lookUpKuhni.Properties.Columns["ITEM_ID"].Visible = false;
            lookUpKuhni.Properties.Columns["NN"].FormatType   = DevExpress.Utils.FormatType.Numeric;
            lookUpKuhni.Properties.Columns["NN"].FormatString = "n0";
            this.Cursor = System.Windows.Forms.Cursors.Default;
        }
        public void refresh_kuhni()
        {
            this.Cursor = System.Windows.Forms.Cursors.WaitCursor;

            OracleConnectionParameters connectionParameters = new OracleConnectionParameters(vivaprocess.Global.ora_serv, "kuhni_modul", "kuhni");
            SqlDataSource ds = new SqlDataSource(connectionParameters);
            // Create an SQL query to access the Products table.
            CustomSqlQuery query = new CustomSqlQuery();

            query.Name = "customQuery1";
            if (chkInWork.Checked == true & chkGotov.Checked == false & chkOtgrugen.Checked == false)
            {
                query.Sql = "select distinct trunc(nvl(prod_id,0)) NN,prod_name NN_клиента,nvl(client_name,' ') клиент,nvl(prod_descr,' ') описание,nvl(to_char(prod_date_in,'dd.mm.yyyy'),' ') дата_поступл,"
                            + " nvl(to_char(prod_date_need,'dd.mm.yy'),' ') отгруз_план,nvl(to_char(date_tehnol,'dd.mm.yy'),' ') в_техотдел,"
                            + " nvl(tehnolog,' ') исполнитель,nvl(prod_cena,0) цена,"
                            + " nvl(to_char(prod_date_otgruzka,'dd.mm.yy'),' ') отгруз_факт,nvl(prod_descr_otgruzka,' ') примечания"
                            + " FROM disp_kuhni where prod_date_otgruzka is null and prod_id in (select t.prod_id from disp_kuhni t where (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy')) and (vse=1 or vse=" + vivaprocess.Global.vse + ") and t.mat_descr<>'нет' and t.sklad_gotov_fakt is null)"
                            + " and (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy')) order by дата_поступл,NN";
            }
            else if (chkInWork.Checked == true & chkGotov.Checked == true & chkOtgrugen.Checked == false)
            {
                query.Sql = "select distinct trunc(nvl(prod_id,0)) NN,prod_name NN_клиента,nvl(client_name,' ') клиент,nvl(prod_descr,' ') описание,nvl(to_char(prod_date_in,'dd.mm.yyyy'),' ') дата_поступл,"
                            + " nvl(to_char(prod_date_need,'dd.mm.yy'),' ') отгруз_план,nvl(to_char(date_tehnol,'dd.mm.yy'),' ') в_техотдел,"
                            + " nvl(tehnolog,' ') исполнитель,nvl(prod_cena,0) цена,"
                            + " nvl(to_char(prod_date_otgruzka,'dd.mm.yy'),' ') отгруз_факт,nvl(prod_descr_otgruzka,' ') примечания"
                            + " FROM disp_kuhni where prod_date_otgruzka is null"
                            + " and (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy') and (vse=1 or vse=" + vivaprocess.Global.vse + ")) order by дата_поступл,NN";
            }
            else if (chkInWork.Checked == true & chkGotov.Checked == true & chkOtgrugen.Checked == true)
            {
                query.Sql = "select distinct trunc(nvl(prod_id,0)) NN,prod_name NN_клиента,nvl(client_name,' ') клиент,nvl(prod_descr,' ') описание,nvl(to_char(prod_date_in,'dd.mm.yyyy'),' ') дата_поступл,"
                            + " nvl(to_char(prod_date_need,'dd.mm.yy'),' ') отгруз_план,nvl(to_char(date_tehnol,'dd.mm.yy'),' ') в_техотдел,"
                            + " nvl(tehnolog,' ') исполнитель,nvl(prod_cena,0) цена,"
                            + " nvl(to_char(prod_date_otgruzka,'dd.mm.yy'),' ') отгруз_факт,nvl(prod_descr_otgruzka,' ') примечания"
                            + " FROM disp_kuhni where (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy') and (vse=1 or vse=" + vivaprocess.Global.vse + ")) order by дата_поступл,NN";
            }
            else if (chkInWork.Checked == true & chkGotov.Checked == false & chkOtgrugen.Checked == true)
            {
                query.Sql = "select distinct trunc(nvl(prod_id,0)) NN,prod_name NN_клиента,nvl(client_name,' ') клиент,nvl(prod_descr,' ') описание,nvl(to_char(prod_date_in,'dd.mm.yyyy'),' ') дата_поступл,"
                            + " nvl(to_char(prod_date_need,'dd.mm.yy'),' ') отгруз_план,nvl(to_char(date_tehnol,'dd.mm.yy'),' ') в_техотдел,"
                            + " nvl(tehnolog,' ') исполнитель,nvl(prod_cena,0) цена,"
                            + " nvl(to_char(prod_date_otgruzka,'dd.mm.yy'),' ') отгруз_факт,nvl(prod_descr_otgruzka,' ') примечания"
                            + " FROM disp_kuhni where (prod_date_otgruzka is not null or prod_id in (select t.prod_id from disp_kuhni t where (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy')) and t.mat_descr<>'нет' and t.sklad_gotov_fakt is null))"
                            + " and (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy') and (vse=1 or vse=" + vivaprocess.Global.vse + ")) order by дата_поступл,NN";
            }
            else if (chkInWork.Checked == false & chkGotov.Checked == false & chkOtgrugen.Checked == true)
            {
                query.Sql = "select distinct trunc(nvl(prod_id,0)) NN,prod_name NN_клиента,nvl(client_name,' ') клиент,nvl(prod_descr,' ') описание,nvl(to_char(prod_date_in,'dd.mm.yyyy'),' ') дата_поступл,"
                            + " nvl(to_char(prod_date_need,'dd.mm.yy'),' ') отгруз_план,nvl(to_char(date_tehnol,'dd.mm.yy'),' ') в_техотдел,"
                            + " nvl(tehnolog,' ') исполнитель,nvl(prod_cena,0) цена,"
                            + " nvl(to_char(prod_date_otgruzka,'dd.mm.yy'),' ') отгруз_факт,nvl(prod_descr_otgruzka,' ') примечания"
                            + " FROM disp_kuhni where prod_date_otgruzka is not null"
                            + " and (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy') and (vse=1 or vse=" + vivaprocess.Global.vse + ")) order by дата_поступл,NN";
            }
            else if (chkInWork.Checked == false & chkGotov.Checked == true & chkOtgrugen.Checked == false)
            {
                query.Sql = "select distinct trunc(nvl(prod_id,0)) NN,prod_name NN_клиента,nvl(client_name,' ') клиент,nvl(prod_descr,' ') описание,nvl(to_char(prod_date_in,'dd.mm.yyyy'),' ') дата_поступл,"
                            + " nvl(to_char(prod_date_need,'dd.mm.yy'),' ') отгруз_план,nvl(to_char(date_tehnol,'dd.mm.yy'),' ') в_техотдел,"
                            + " nvl(tehnolog,' ') исполнитель,nvl(prod_cena,0) цена,"
                            + " nvl(to_char(prod_date_otgruzka,'dd.mm.yy'),' ') отгруз_факт,nvl(prod_descr_otgruzka,' ') примечания"
                            + " FROM disp_kuhni where (prod_date_otgruzka is null and prod_id not in (select t.prod_id from disp_kuhni t where (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy')) and t.mat_descr<>'нет' and t.sklad_gotov_fakt is null))"
                            + " and (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy') and (vse=1 or vse=" + vivaprocess.Global.vse + ")) order by дата_поступл,NN";
            }
            else if (chkInWork.Checked == false & chkGotov.Checked == true & chkOtgrugen.Checked == true)
            {
                query.Sql = "select trunc(nvl(prod_id,0)) NN,prod_name NN_клиента,nvl(client_name,' ') клиент,nvl(prod_descr,' ') описание,nvl(to_char(prod_date_in,'dd.mm.yyyy'),' ') дата_поступл,"
                            + " nvl(to_char(prod_date_need,'dd.mm.yy'),' ') отгруз_план,nvl(to_char(date_tehnol,'dd.mm.yy'),' ') в_техотдел,"
                            + " nvl(tehnolog,' ') исполнитель,nvl(prod_cena,0) цена,"
                            + " nvl(to_char(prod_date_otgruzka,'dd.mm.yy'),' ') отгруз_факт,nvl(prod_descr_otgruzka,' ') примечания"
                            + " FROM disp_kuhni where (prod_date_otgruzka is not null or prod_id not in (select t.prod_id from disp_kuhni t where (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy')) and t.mat_descr<>'нет' and t.sklad_gotov_fakt is null))"
                            + " and (prod_date_in between to_date('" + dateStart.Text + "','dd.mm.yyyy') and to_date('" + dateEnd.Text + "','dd.mm.yyyy') and (vse=1 or vse=" + vivaprocess.Global.vse + ")) order by дата_поступл,NN";
            }
            else
            {
                this.Cursor = System.Windows.Forms.Cursors.Default;
                return;
            }
            ds.Queries.Add(query);
            ds.Fill();
            //Assign the data source for the grid and retrieve fields.
            gridControl1.DataSource = ds;
            gridControl1.DataMember = "customQuery1";
            gridView1.Columns["NN"].DisplayFormat.FormatType     = DevExpress.Utils.FormatType.Numeric;
            gridView1.Columns["NN"].DisplayFormat.FormatString   = "n0";
            gridView1.Columns["ЦЕНА"].DisplayFormat.FormatType   = DevExpress.Utils.FormatType.Numeric;
            gridView1.Columns["ЦЕНА"].DisplayFormat.FormatString = "n2";
            if (vivaprocess.Global.prava == "технолог" || vivaprocess.Global.prava == "цех" || vivaprocess.Global.prava == "склад продукции" || vivaprocess.Global.prava == "снабжение")
            {
                gridView1.Columns["ЦЕНА"].Visible = false;
            }
            gridView1.BestFitColumns();

            /*gridView1.Columns["ДАТА"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["ДАТА"].DisplayFormat.FormatString = "dd.M.yyyy";
             * gridView1.Columns["ОТГРУЗ_ПЛАН"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["ОТГРУЗ_ПЛАН"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["В_ТЕХОТДЕЛ"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["В_ТЕХОТДЕЛ"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["ПРОИЗВ_ПЛАН"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["ПРОИЗВ_ПЛАН"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["ПРОИЗВ_ФАКТ"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["ПРОИЗВ_ФАКТ"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["КРАСКА_ПЛАН"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["КРАСКА_ПЛАН"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["КРАСКА_ФАКТ"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["КРАСКА_ФАКТ"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["ОТК_ПЛАН"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["ОТК_ПЛАН"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["ОТК_ФАКТ"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["ОТК_ФАКТ"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["СБОРКА_ПЛАН"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["СБОРКА_ПЛАН"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["СБОРКА_ФАКТ"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["СБОРКА_ФАКТ"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["СКЛ_ГОТ_ПЛАН"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["СКЛ_ГОТ_ПЛАН"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["СКЛ_ГОТ_ФАКТ"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["СКЛ_ГОТ_ФАКТ"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["СНАБЖ_ЗАЯВКА"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["СНАБЖ_ЗАЯВКА"].DisplayFormat.FormatString = "d";
             * gridView1.Columns["ОТГРУЗ_ФАКТ"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
             * gridView1.Columns["ОТГРУЗ_ФАКТ"].DisplayFormat.FormatString = "d";*/
            this.Cursor = System.Windows.Forms.Cursors.Default;
        }