protected void Button2_Click(object sender, EventArgs e)
        {
            Delete_Leitourgika.Delete(); // delete from EXODA
                                         //   Kin_Logariasmon.Delete();
                                         //Exoda_Metafora_Leit.Delete();  Update Exoda - the deleted from exoda leitourgika to Exoda
            Kin_Logariasmon.Delete();

            Exoda_Leitourgika.Delete();

            GridView1.DataBind();


            GridView2.DataBind();
            GridView3.DataBind();
            Delete_LeftOvers.Delete();
            Delete_LeftOvers.Update();
            GridView1.SelectedIndex = -1;

            //        DropDownList2.SelectedValue= "0";
            DropDownList2_SelectedIndexChanged(null, null);
            DropDownList4.SelectedValue  = "0";
            DropDownList5.SelectedValue  = "0";
            DropDownList7.SelectedValue  = "0";
            DropDownList8.SelectedValue  = "0";
            DropDownList10.SelectedValue = "0";

            TextBox1.Text   = "";
            TextBox2.Text   = "";
            TextBox26.Text  = "";
            TextBox27.Text  = "";
            TextBox3.Text   = "";
            Button2.Enabled = false;
            Ypoloipo_Code.DataBind();
            Ypoloipo_Code_LC.DataBind();
            GridView2.DataBind();
            GridView3.DataBind();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            TextBox34.Text            = "0";
            TextBox35.Text            = "0";
            TextBox36.Text            = "0";
            TextBox37.Text            = "0";
            Session["Months"]         = DropDownList5.SelectedValue;
            Session["Desc_esoda"]     = TextBox1.Text;
            Session["Etos"]           = DropDownList1.SelectedValue;
            Session["Date_Apostolis"] = TextBox3.Text;
            Session["Xrisi_I"]        = TextBox6.Text;

            Session["GR_Eiprajeis"] = DropDownList2.SelectedValue;
            Session["Code_leit"]    = DropDownList2.SelectedValue;



            if (DropDownList3.SelectedValue == "0" || DropDownList2.SelectedValue.Length == 0 || TextBox1.Text.Length == 0 || (TextBox2.Text.Length == 0 && TextBox8.Text == "0") || (TextBox26.Text.Length == 0 && TextBox8.Text == "1") || TextBox3.Text.Length == 0 || DropDownList2.SelectedValue.Length == 0 || TextBox27.Text.Length == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                        "alertMessage",
                                                        "alert('Δεν έχει επιλεγεί Κωδικός ή Ημερομηνία Εξόδου ή Δεν έχει συμπληρωθεί το Ποσό ή Περιγραφή Εξόδου ή δεν έχει επιλεγεί Μήνας Υπολ. Δαπάνης !!!!');", true);
            }
            else
            {
                if (FINANCIAL_MANAGEMENT.App_Code.xrisi.Fetch_Isotimia() == 1)
                {
                    if (TextBox2.Text.Length == 0)
                    {
                        TextBox2.Text = Math.Round((Convert.ToDecimal(TextBox26.Text) / Convert.ToDecimal(TextBox38.Text)), 2).ToString();
                    }
                    if (TextBox26.Text.Length == 0)
                    {
                        TextBox26.Text = Math.Round((Convert.ToDecimal(TextBox2.Text) * Convert.ToDecimal(TextBox38.Text)), 2).ToString();
                    }
                }

                TextBox5.Text = "28/" + TextBox27.Text + "/" + DropDownList1.Text;
                DateTime dateTime = Convert.ToDateTime(this.TextBox5.Text.Trim(), new CultureInfo("en-GB"));
                this.TextBox5.Text = dateTime.AddDays(60).ToString("dd/MM/yyyy");
                if (Convert.ToDateTime(TextBox3.Text) != Convert.ToDateTime(TextBox5.Text))
                {
                    TextBox4.Text = DateTime.Now.ToString();
                    Exoda_Leitourgika.Insert();
                    Kin_Logariasmon.Insert();

                    if (TextBox28.Text.Length > 0 && Convert.ToInt16(TextBox28.Text) > 0)
                    {
                        // AN EXEI SIMPLIROMATIKO PROTA TO POSO APO TO 1 GRAMMATEIO META APO TO 2  GR  KAI META PARAKATO TO YPOLOIPO EJ IDION
                        if (TextBox8.Text == "0" && Convert.ToDecimal(GridView2.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView2.Rows[0].Cells[2].Text) > 0 && Convert.ToDecimal(string.IsNullOrEmpty(TextBox2.Text) ? "0" : TextBox2.Text) > Convert.ToDecimal(GridView2.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView2.Rows[0].Cells[2].Text))
                        {
                            TextBox34.Text = (Convert.ToDecimal(GridView2.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView2.Rows[0].Cells[2].Text)).ToString(); //EYRO
                        }

                        if (TextBox8.Text == "1" && Convert.ToDecimal(GridView3.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView3.Rows[0].Cells[2].Text) > 0 && Convert.ToDecimal(string.IsNullOrEmpty(TextBox26.Text) ? "0" : TextBox26.Text) > Convert.ToDecimal(GridView3.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView3.Rows[0].Cells[2].Text))
                        {
                            TextBox35.Text = (Convert.ToDecimal(GridView3.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView3.Rows[0].Cells[2].Text)).ToString(); //T.N.
                        }
                        if (Convert.ToDecimal(GridView3.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView3.Rows[0].Cells[2].Text) > 0 || Convert.ToDecimal(GridView2.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView2.Rows[0].Cells[2].Text) > 0)
                        {
                            Exoda_Metafora_Leit.Update();
                            Exoda_Metafora_Leit.Insert();
                            Delete_Leitourgika.Insert();
                        }

                        if (TextBox8.Text == "0" && Convert.ToDecimal(GridView2.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView2.Rows[0].Cells[2].Text) - Convert.ToDecimal(string.IsNullOrEmpty(TextBox2.Text) ? "0" : TextBox2.Text) < 0 && Convert.ToDecimal(GridView2.Rows[0].Cells[1].Text) > 0)
                        {
                            if (Convert.ToDecimal(GridView2.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView2.Rows[0].Cells[2].Text) - Convert.ToDecimal(string.IsNullOrEmpty(TextBox2.Text) ? "0" : TextBox2.Text) + Convert.ToDecimal(GridView2.Rows[0].Cells[1].Text) >= 0)
                            {
                                if (Convert.ToDecimal(GridView2.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView2.Rows[0].Cells[2].Text) - Convert.ToDecimal(string.IsNullOrEmpty(TextBox2.Text) ? "0" : TextBox2.Text) + Convert.ToDecimal(GridView2.Rows[0].Cells[1].Text) > Convert.ToDecimal(string.IsNullOrEmpty(TextBox2.Text) ? "0" : TextBox2.Text))
                                {
                                    TextBox36.Text = Convert.ToDecimal(string.IsNullOrEmpty(TextBox2.Text) ? "0" : TextBox2.Text).ToString();
                                }
                                else
                                {
                                    TextBox36.Text = (Math.Abs(Convert.ToDecimal(GridView2.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView2.Rows[0].Cells[2].Text) - Convert.ToDecimal(string.IsNullOrEmpty(TextBox2.Text) ? "0" : TextBox2.Text))).ToString();  //EYRO
                                }
                            }
                            else
                            {
                                if (Convert.ToDecimal(GridView2.Rows[0].Cells[3].Text) > Convert.ToDecimal(GridView2.Rows[0].Cells[1].Text))
                                {
                                    TextBox36.Text = GridView2.Rows[0].Cells[3].Text;
                                }
                                else
                                {
                                    TextBox36.Text = GridView2.Rows[0].Cells[1].Text;
                                }
                            }
                        }


                        if (TextBox8.Text == "1" && Convert.ToDecimal(GridView3.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView3.Rows[0].Cells[2].Text) - Convert.ToDecimal(string.IsNullOrEmpty(TextBox26.Text) ? "0" : TextBox26.Text) < 0 && Convert.ToDecimal(GridView3.Rows[0].Cells[1].Text) > 0)
                        {
                            if (Convert.ToDecimal(GridView3.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView3.Rows[0].Cells[2].Text) - Convert.ToDecimal(string.IsNullOrEmpty(TextBox26.Text) ? "0" : TextBox26.Text) + Convert.ToDecimal(GridView3.Rows[0].Cells[1].Text) >= 0)
                            {
                                if (Convert.ToDecimal(GridView3.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView3.Rows[0].Cells[2].Text) - Convert.ToDecimal(string.IsNullOrEmpty(TextBox26.Text) ? "0" : TextBox26.Text) + Convert.ToDecimal(GridView3.Rows[0].Cells[1].Text) > Convert.ToDecimal(string.IsNullOrEmpty(TextBox26.Text) ? "0" : TextBox26.Text))
                                {
                                    TextBox37.Text = Convert.ToDecimal(string.IsNullOrEmpty(TextBox26.Text) ? "0" : TextBox26.Text).ToString();
                                }
                                else
                                {
                                    TextBox37.Text = (Math.Abs(Convert.ToDecimal(GridView3.Rows[0].Cells[0].Text) - Convert.ToDecimal(GridView3.Rows[0].Cells[2].Text) - Convert.ToDecimal(string.IsNullOrEmpty(TextBox26.Text) ? "0" : TextBox26.Text))).ToString();  //T.N.
                                }
                            }
                            else
                            {
                                if (Convert.ToDecimal(GridView3.Rows[0].Cells[3].Text) > Convert.ToDecimal(GridView3.Rows[0].Cells[1].Text))
                                {
                                    TextBox37.Text = GridView3.Rows[0].Cells[3].Text;
                                }
                                else
                                {
                                    TextBox37.Text = GridView3.Rows[0].Cells[1].Text;
                                }
                            }
                        }

                        if (Convert.ToDecimal(string.IsNullOrEmpty(TextBox36.Text) ? "0" : TextBox36.Text) > 0 || Convert.ToDecimal(string.IsNullOrEmpty(TextBox37.Text) ? "0" : TextBox37.Text) > 0)
                        {
                            Exoda_Metafora_Leit_Simpl_GR.Update();
                            Exoda_Metafora_Leit_Simpl_GR.Insert();
                            Delete_Leitourgika.Update();
                        }
                    }

                    if (DropDownList8.SelectedValue != "0")
                    {
                        Logariasmoi_To.Insert();
                        Logariasmoi_To.Delete();
                    }
                    //                  DropDownList2.SelectedValue= 0;



                    if (TextBox8.Text == "0" && Convert.ToDecimal(TextBox2.Text) > Convert.ToDecimal(GridView2.Rows[0].Cells[3].Text))
                    {
                        //// εδω αλλαγή EVRO !!!
                        decimal Ypoloipo_EE = Convert.ToDecimal(GridView2.Rows[0].Cells[3].Text);
                        if (Ypoloipo_EE < 0)
                        {
                            Ypoloipo_EE = 0;
                        }

                        Session["Poso_exidion_LC"] = "0";
                        Session["Poso_exidion"]    = (Convert.ToDecimal(TextBox2.Text) - Ypoloipo_EE).ToString();
                        ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( '../Leitourgika/Katathesi_ExIdion.aspx', null, 'height=300,width=380,status=yes,toolbar=no,scrollbars=no,menubar=no,location=no, left=\'+Mleft+\'' );", true);
                    }
                    if (TextBox8.Text == "1" && Convert.ToDecimal(TextBox26.Text) > Convert.ToDecimal(GridView3.Rows[0].Cells[3].Text))
                    {
                        //// εδω αλλαγή TN !!!
                        decimal Ypoloipo_LC = Convert.ToDecimal(GridView3.Rows[0].Cells[3].Text);
                        if (Ypoloipo_LC < 0)
                        {
                            Ypoloipo_LC = 0;
                        }

                        Session["Poso_exidion"]    = "0";
                        Session["Poso_exidion_LC"] = (Convert.ToDecimal(TextBox26.Text) - Ypoloipo_LC).ToString();
                        ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( '../Leitourgika/Katathesi_ExIdion.aspx', null, 'height=300,width=380,status=yes,toolbar=no,scrollbars=no,menubar=no,location=no, left=\'+Mleft+\'' );", true);
                    }

                    DropDownList2_SelectedIndexChanged(null, null);

                    DropDownList4.SelectedValue  = "0";
                    DropDownList5.SelectedValue  = "0";
                    DropDownList7.SelectedValue  = "0";
                    DropDownList8.SelectedValue  = "0";
                    DropDownList10.SelectedValue = "0";
                    Ypoloipo_Code.DataBind();
                    Ypoloipo_Code_LC.DataBind();
                    GridView2.DataBind();
                    GridView3.DataBind();
                    TextBox1.Text  = "";
                    TextBox2.Text  = "";
                    TextBox26.Text = "";
                    TextBox27.Text = "";
                    TextBox41.Text = "";
                    TextBox3.Text  = "";


                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                            "alertMessage",
                                                            "alert('Επιτυχής Αποθήκευση!!!!');", true);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
                                                            "alertMessage",
                                                            "alert('Λανθασμένη επιλογή Ημερομηνίας - Μήνας ή Έτος!!!!');", true);
                }
            }
        }