Esempio n. 1
0
        public printDyeingOutward(DataRow row, M_V4_printDyeingOutward f)
        {
            InitializeComponent();
            this.c      = new DbConnect();
            this.parent = f;
            if (row.Table.Columns.Count < 3)
            {
                return;
            }

            //Load firm details
            DataTable dt10 = c.runQuery("SELECT * FROM Defaults WHERE Default_Type= 'Print' and default_name = 'Default Print Type'");
            string    default_print_type_id = dt10.Rows[0]["Default_Value"].ToString();

            DataTable dt_printTypes = c.runQuery("select * from Print_Types where Print_Type_ID=" + default_print_type_id);

            if (dt_printTypes == null)
            {
                c.WarningBox("Print->Default Print Type is set as " + default_print_type_id + ", not found in Default Print_Type_IDs Table, " +
                             "defaulting to first entry in Print_Types table");
                dt_printTypes = c.runQuery("select * from Print_Types");
            }
            for (int j = 0; j < dt_printTypes.Columns.Count - 1; j++)
            {
                firmDetails[dt_printTypes.Columns[j].ColumnName] = dt_printTypes.Rows[0][j].ToString();
            }

            this.batchnoTextbox.Text = row["Batch_No"].ToString();
            //this.dateTimePicker1.Value = Convert.ToDateTime(row["Input_Date"].ToString());
            this.outDateTextbox.Text      = row["Dyeing_Out_Date"].ToString().Substring(0, 10);
            this.customerNameTextbox.Text = row["Dyeing_Company_Name"].ToString();
            this.qualityTextbox.Text      = row["Quality"].ToString();
            this.shadeTextbox.Text        = row["Colour"].ToString();
            DataTable dyeing_company = c.getTableRows("Dyeing_Company_Names", "Dyeing_Company_Names='" + row["Dyeing_Company_Name"].ToString() + "'");

            this.customerAddressTextbox.Text = dyeing_company.Rows[0]["Customer_Address"].ToString();
            this.customergstin.Text          = dyeing_company.Rows[0]["GSTIN"].ToString();
            DataTable quality = c.getTableRows("Quality", "Quality='" + row["Quality"].ToString() + "'");

            this.hsnnumber.Text = quality.Rows[0]["HSN_No"].ToString();
            this.label6.Text    = "(GSTIN No. " + firmDetails["GSTIN"] + ")";
            this.label5.Text    = firmDetails["Address"];
            this.label3.Text    = firmDetails["Firm_Name"];
            string[] tray_ids = c.csvToArray(row["Tray_ID_Arr"].ToString());
            if (!string.IsNullOrEmpty(row["Redyeing"].ToString()))
            {
                this.redyeing        = true;
                this.rdLabel.Visible = true;
            }
            DataTable dt = new DataTable();

            dt.Columns.Add("Sl No");
            dt.Columns.Add("Tray No.");
            dt.Columns.Add("Gross Wt");
            dt.Columns.Add("Tray Wt");
            dt.Columns.Add("MNo");
            dt.Columns.Add("Springs");
            dt.Columns.Add("Spring Wt");
            dt.Columns.Add("Net Wt");
            float net_wt        = 0F;
            int   total_springs = 0;

            for (int i = 0; i < tray_ids.Length; i++)
            {
                DataTable dtemp         = c.getTrayTable_TrayID(int.Parse(tray_ids[i]));
                int       no_of_springs = int.Parse(dtemp.Rows[0]["Number_Of_Springs"].ToString());
                float     spring_wt     = c.getSpringWeight(dtemp.Rows[0]["Spring"].ToString()) * no_of_springs;
                float     gross_wt      = float.Parse(dtemp.Rows[0]["Gross_Weight"].ToString());
                float     tray_wt       = float.Parse(dtemp.Rows[0]["Net_Weight"].ToString());
                if (row["Dyeing_Company_Name"].ToString() == "Ichalkaranji Textiles Pvt Ltd")
                {
                    gross_wt -= 1.25F;
                    tray_wt  -= 1.25F;
                }
                net_wt        += tray_wt;
                total_springs += no_of_springs;
                dt.Rows.Add(i + 1, dtemp.Rows[0]["Tray_No"].ToString(), gross_wt, dtemp.Rows[0]["Tray_Tare"].ToString(), dtemp.Rows[0]["Machine_No"].ToString(), dtemp.Rows[0]["Number_of_Springs"].ToString(), spring_wt, tray_wt);
            }
            this.netwtTextbox.Text = net_wt.ToString("F3");

            dt.Rows.Add("", "", "", "", "Total Springs", total_springs, "Net Weight", net_wt);
            dataGridView1.DataSource = dt;
            int weight_width = 100;

            dataGridView1.Columns["Sl No"].Width              = 70;
            dataGridView1.Columns["Tray No."].Width           = 100;
            dataGridView1.Columns["Gross Wt"].Width           = weight_width;
            dataGridView1.Columns["Tray Wt"].Width            = weight_width;
            dataGridView1.Columns["MNo"].Width                = 50;
            dataGridView1.Columns["Springs"].Width            = 50;
            dataGridView1.Columns["Spring Wt"].Width          = weight_width;
            dataGridView1.Columns["Net Wt"].Width             = weight_width;
            dataGridView1.DefaultCellStyle.SelectionBackColor = Color.White;
            dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Black;
            dataGridView1.Columns.Cast <DataGridViewColumn>().ToList().ForEach(t => t.SortMode = DataGridViewColumnSortMode.NotSortable);
            c.auto_adjust_dgv(dataGridView1);
            dataGridView1.Columns["Sl No"].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            dataGridView1.Columns["Sl No"].Width        = 80;
            c.set_dgv_column_sort_state(dataGridView1, DataGridViewColumnSortMode.NotSortable);
            this.where = "Batch_No=" + this.batchnoTextbox.Text + " AND Fiscal_Year='" + row["Fiscal_Year"].ToString() + "'";

            this.label3.Text = firmDetails["Firm_Name"];
            this.label5.Text = firmDetails["Address"];
            this.label6.Text = "(GSTIN No. " + firmDetails["GSTIN"] + ")";
            PrinterSettings ps = new PrinterSettings();

            printDocument1.PrinterSettings = ps;
            IEnumerable <PaperSize> paperSizes = ps.PaperSizes.Cast <PaperSize>();
            PaperSize sizeA4 = paperSizes.First <PaperSize>(size => size.Kind == PaperKind.A4); // setting paper size to A4 size

            printDocument1.DefaultPageSettings.PaperSize = sizeA4;
        }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     M_V4_printDyeingOutward f = new M_V4_printDyeingOutward();
     Global.background.show_form(f);
 }