예제 #1
0
    protected void btnCorrect_Click(object sender, EventArgs e)
    {
        if ((cmbCounter.SelectedValue != "-1") && (cmbStatus.SelectedValue != "-1") && (txtReceiptno.Text != ""))
        {
            string q_dayend = "SELECT DISTINCT DATE_FORMAT(dayend,'%d-%m-%Y') FROM t_roomallocation WHERE adv_recieptno=" + txtReceiptno.Text + " AND counter_id=" + cmbCounter.SelectedValue + "";
            string dayend   = objcls.exeScalar(q_dayend);
            if (dayend != "")
            {
                string dayendnew     = objcls.yearmonthdate(dayend);
                string q_dayendcheck = "SELECT DATE_FORMAT(closedate_start,'%d-%m-%Y') AS closedate_start FROM  t_dayclosing WHERE daystatus='open' AND DATE_FORMAT(closedate_start,'%d-%m-%Y')='" + dayend + "'";
                string dayendcheck   = objcls.exeScalar(q_dayendcheck);
                if (dayendcheck != "")
                {
                    int correctid = objcls.PK_exeSaclarInt("crct_id", "t_receiptcorrection");
                    correctid = correctid + 1;
                    OdbcTransaction odbTrans = null;
                    try
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.ConnectionString = strConnection;
                            con.Open();
                        }
                        odbTrans = con.BeginTransaction();
                        int         receiptno       = Convert.ToInt32(txtReceiptno.Text) + 1;
                        string      q_receiptstatus = @"INSERT INTO t_receiptcorrection(crct_id,counter_no,recipt_no,crct_status,crct_date,dayend)
VALUES (" + correctid + "," + cmbCounter.SelectedValue + "," + txtReceiptno.Text + "," + cmbStatus.SelectedValue + ",now(),'" + dayendnew + "')";
                        OdbcCommand cmd1            = new OdbcCommand(q_receiptstatus, con);
                        cmd1.Transaction = odbTrans;
                        cmd1.ExecuteNonQuery();
                        string      q_correct = @"UPDATE t_roomallocation SET adv_recieptno=adv_recieptno+1 WHERE adv_recieptno>=" + txtReceiptno.Text + " AND counter_id=" + cmbCounter.SelectedValue + "";
                        OdbcCommand cmd2      = new OdbcCommand(q_correct, con);
                        cmd2.Transaction = odbTrans;
                        cmd2.ExecuteNonQuery();
                        odbTrans.Commit();
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "ShowUpdated();", true);
                        clear();
                    }
                    catch
                    {
                        odbTrans.Rollback();
                        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "ShowError();", true);
                        clear();
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showdate();", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "ShowRequired();", true);
            }
        }
    }
예제 #2
0
    protected void txtendduration_TextChanged(object sender, EventArgs e)
    {
        string qa          = @"select ifnull(max(end_duration),0) from m_rent where row_status!=2 AND room_category=" + cmbroom.SelectedValue + " and reservation_type=" + cmbreserve.SelectedValue + "";
        string endduration = objcls.exeScalar(qa);

        if (int.Parse(txtendduration.Text) < int.Parse(endduration))
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showtimeslot();", true);
        }
    }