Ejemplo n.º 1
0
        protected void bSave_Click(object sender, ImageClickEventArgs e)
        {
            lock (Database.lockObjectDB)
            {
                ArrayList al = new ArrayList();

                string s = "";

                if (DatePickerStart.DatePickerText != "")
                {
                    try
                    {
                        Convert.ToDateTime(DatePickerStart.DatePickerText);
                    }
                    catch
                    {
                        lbInform.Text = "Неправильно введена дата документа с";
                        DatePickerStart.Focus();
                        return;
                    }
                }
                if (DatePickerEnd.DatePickerText != "")
                {
                    try
                    {
                        Convert.ToDateTime(DatePickerEnd.DatePickerText);
                    }
                    catch
                    {
                        lbInform.Text = "Неправильно введена дата документа по";
                        DatePickerEnd.Focus();
                        return;
                    }
                }

                if (DatePickerStart.DatePickerText != "")
                {
                    al.Add(String.Format("(date_doc>=[{0:" + ConfigurationSettings.AppSettings["DateFormat"] + "}])", DatePickerStart.SelectedDate));
                }
                if (DatePickerEnd.DatePickerText != "")
                {
                    al.Add(String.Format("(date_doc<=[{0:" + ConfigurationSettings.AppSettings["DateFormat"] + "}])", DatePickerEnd.SelectedDate));
                }

                string id_type = dListType.SelectedItem.Value;
                if (id_type != "-1")
                {
                    al.Add(String.Format("(type={0})", id_type));
                }

                id_type = dListBranch.SelectedItem.Value;
                if (id_type != "-1")
                {
                    al.Add($"(id_branch={id_type})");
                }

                if (tbProd.Text != "")
                {
                    al.Add(String.Format("(id in (select id_doc from V_Products_StorageDocs where prod_name like [%{0}%]))", tbProd.Text));
                }

                if (tbCard.Text != "")
                {
                    if (tbCard.Text.Trim().Length >= 16)
                    {
                        al.Add(
                            $"(id in (select id_doc from V_Cards_StorageDocs where panhash like [{FuncClass.GetHashPan(tbCard.Text.Trim())}]))");
                    }
                    else
                    {
                        al.Add($"(id in (select id_doc from V_Cards_StorageDocs where pan like [%{tbCard.Text.Trim()}%]))");
                    }
                }

                if (tbCreate.Text != "")
                {
                    al.Add(String.Format("(loweredusername like [%{0}%])", tbCreate.Text.Trim()));
                }

                if (chAll.Checked)
                {
                    al.Add(String.Format("(priz_gen=1 or priz_gen=0)", tbCard.Text));
                }
                else
                {
                    al.Add(String.Format("(priz_gen=0)", tbCard.Text));
                }

                if (al.Count > 0)
                {
                    string[] all = Array.CreateInstance(typeof(string), al.Count) as string[];
                    al.CopyTo(all, 0);
                    s = "where " + String.Join(" and ", all);
                }

                Response.Write("<script language=javascript>window.returnValue='" + s + "'; window.close();</script>");
            }
        }